Thread: Thread-Safe Functions

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Mar 2008
    Posts
    14

    Thread-Safe Functions

    Hello,

    I was wondering how to make malloc() thread safe. Could I just use a mutex everytime I use malloc() in my code example

    Code:
    pthread_mutex_lock(&malloc_mutex);
       // Malloc Code here
    pthread_mutex_unlock(&malloc_mutex);
    And if that's the case could I make any function thread safe that way?

    Thanks,
    scioner
    Last edited by scioner; 04-17-2008 at 09:58 AM. Reason: Missing stuff

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Thread Prog in C language (seg fault)
    By kumars in forum C Programming
    Replies: 22
    Last Post: 10-09-2008, 01:17 PM
  2. are winsock functions thread safe?
    By *DEAD* in forum Networking/Device Communication
    Replies: 2
    Last Post: 12-15-2007, 10:37 AM
  3. Thread Synchronization in Win32
    By passionate_guy in forum C Programming
    Replies: 0
    Last Post: 02-06-2006, 05:34 AM
  4. multithreading question
    By ichijoji in forum C++ Programming
    Replies: 7
    Last Post: 04-12-2005, 10:59 PM
  5. Replies: 12
    Last Post: 05-17-2003, 05:58 AM