parallel programming part two.

Discussion in 'Mac Programming' started by farmerdoug, Oct 15, 2008.

  1. farmerdoug macrumors 6502a

    Joined:
    Sep 16, 2008
    #1
    I now have a program which successfully runs multiple threads. When I add a call to a function in an external library it fails if there is more than one thread. The error says "too many I/O drivers". Without knowing the specifics of the library (CFITSIO for manipulating fits files), does anybody have any insight into this error.

    Thanks.
     
  2. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #2
    Some libraries are not thread safe. Check the documentation to make sure.
     
  3. varsis macrumors regular

    Joined:
    Nov 30, 2005
    #3
    Agreed. I think that is your problem. Have you tried using a non threaded version?

    Chris
     
  4. farmerdoug thread starter macrumors 6502a

    Joined:
    Sep 16, 2008
    #4
    pp part 2

    A non threaded version of the code?. That defeats it's purpose. I need speed. There are other work arounds though.
     
  5. Sander macrumors 6502

    Joined:
    Apr 24, 2008
    #5
    You can also try serializing just the access to this particular library (unless the bulk of the work happens in there, in which case it indeed would defeat the purpose).
     
  6. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #6
    You could use multiple sub-processes instead of threads. The sub-processes would be single threaded so no issues with the library.
     
  7. gnasher729 macrumors P6

    gnasher729

    Joined:
    Nov 25, 2005
    #7
    If the library is not thread safe, try protecting all calls to it with a mutex. Or maybe the library wants to be initialised _once_, and each one of your threads initialises it.
     
  8. farmerdoug thread starter macrumors 6502a

    Joined:
    Sep 16, 2008
    #8
    mutex

    Thanks. I will look into this. Unfortunately, my knowledge does not extend far enough to understand your suggestion. I'll try google but if you could be more specific, I would appreciate it.
     

Share This Page