pthreads and semaphores

pthreads and semaphores

Post by Greg Ricke » Sat, 02 Aug 1997 04:00:00



Hi,
       I am trying to move an application on to Linux that uses Posix
pthreads and semaphores.
So far I have found what I need for pthreads under Linux but I can't
find anything support
for the semaphore stuff(sem_init,sem_open,sem_post,....). I am just
missing something or
does Linux not support this yet. I am running RedHat Linux 4.2.

Thanks,

  Greg Ricker

 
 
 

1. Are pthreads' semaphores supposed to do this or is it a Linux bug?

By mistake, I had coded (in pseudo code)

Program Initialization
    Initialize semaphore with sem_init()
    acquire semaphore with sem_wait()
    if( Optional Test )
        {
        ...
        release semaphore with sem_post()
        }
    ...

Program Processing
    ...

Program Termination
    acquire semaphore with sem_wait()
    ...

And didn't execute the optional test and the program hung.  Fine, I
understand that.  But then I changed the last sem_wait() to sem_trywait()
and the program still hung.  That I don't understand.  Is this a bug or is
there something in these semaphores that hangs when a program tries to wait
on a semaphore that it already has acquired?

FWIW, It's gcc-2.95.3 & libc-5.3.12-31.

    TIA
        Norm

2. Does Enterprise Server Cache Documents?

3. Process shared semaphores (Pthreads)

4. Slackware Installation problems

5. shared memory semaphores / pthread mutexes?

6. StarOffice 4.0 Problems...

7. pthread - threads and semaphores - help!

8. Warning!! If taking HP training....

9. Matrox Mystique ands X.

10. Increasing # of semaphores in semaphore set?

11. Sys V Semaphores vs. POSIX Semaphores??

12. accept()-like wait for semaphore AND socket?

13. semaphores