diff options
author | rpj <rpj> | 2004-10-22 15:06:41 +0000 |
---|---|---|
committer | rpj <rpj> | 2004-10-22 15:06:41 +0000 |
commit | 045278e11b53fc1ad59945427feab1cd9275988f (patch) | |
tree | da8570a7a8962d9563814c4910e8a9d5fb6fa685 /sem_init.c | |
parent | f84df26e12431bb9ecd07fbc52c804538635901f (diff) |
Changes to mutexes and semaphores - considered alpha for now
Diffstat (limited to 'sem_init.c')
-rw-r--r-- | sem_init.c | 24 |
1 files changed, 17 insertions, 7 deletions
@@ -128,17 +128,27 @@ sem_init (sem_t * sem, int pshared, unsigned int value) #else /* NEED_SEM */ s->value = value; - s->sem = CreateSemaphore (NULL, /* Always NULL */ - (long) 0, /* Force threads to wait */ - (long) _POSIX_SEM_VALUE_MAX, /* Maximum value */ - NULL); /* Name */ - - if (0 == s->sem) + if (pthread_mutex_init(&s->lock, NULL) == 0) + { + if ((s->sem = CreateSemaphore (NULL, /* Always NULL */ + (long) 0, /* Force threads to wait */ + (long) _POSIX_SEM_VALUE_MAX, /* Maximum value */ + NULL)) == 0) /* Name */ + { + (void) pthread_mutex_destroy(&s->lock); + result = ENOSPC; + } + } + else { - free (s); result = ENOSPC; } + if (result != 0) + { + free(s); + } + #endif /* NEED_SEM */ } |