Thread: pthread problem 2

  1. #1
    Registered User
    Join Date
    Aug 2002
    Posts
    351

    pthread problem 2

    i have one c code file that is responsible for creating, starting and controlling a poll of threads. when a thread is called it calls a function included in a seperate c code file.

    so, this function is called by many threads. i thought this method (seoperation of files) would cause each thread to call a different instance of that function.

    it now seems obvious that the present method is the same as including all the code in the same file. this causes problems with the threads having access to the same global variables.

    i don't want mutual exclusion, but complete exclusion. i.e. different instances of the second file being called like in OO programming.

    is there an easy method of doing this?

    how is this achieved in standard libraries?

    TIA,

    rotis23

  2. #2
    Registered User
    Join Date
    Aug 2002
    Posts
    351
    i solved the problem by eliminating global variables.

    i think another solution is to define _REENTRANT at the start of the code. not sure though.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  2. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  3. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  4. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM
  5. pthread producer consumer problem
    By Amit Chikorde in forum C Programming
    Replies: 1
    Last Post: 01-17-2007, 07:39 PM