Semaphores are no longer used, remove:

(empth_sem_t, empth_sem_create, empth_sem_signal, empth_sem_wait):
Remove.
[EMPTH_LWP] (lwpSem, lwpCreateSem, lwpSignal, lwpWait): Remove.
[EMPTH_W32] (loc_sem): Remove.
This commit is contained in:
Markus Armbruster 2007-02-08 12:29:16 +00:00
parent c1eb1bd5d2
commit c69cf0d1fd
7 changed files with 0 additions and 286 deletions

View file

@ -132,24 +132,6 @@ empth_wait_for_signal(void)
}
}
empth_sem_t *
empth_sem_create(char *name, int cnt)
{
return lwpCreateSem(name, cnt);
}
void
empth_sem_signal(empth_sem_t *sm)
{
lwpSignal(sm);
}
void
empth_sem_wait(empth_sem_t *sm)
{
lwpWait(sm);
}
empth_rwlock_t *
empth_rwlock_create(char *name)
{

View file

@ -90,21 +90,6 @@ struct loc_Thread {
};
/************************
* loc_Sem
*/
struct loc_Sem {
/* The semaphore name, passed in at create time. */
char szName[17];
/* An Event that the thread(s) will sleep on. */
HANDLE hEvent;
/* The count variable */
int count;
};
/************************
* loc_RWLock
*
@ -640,66 +625,6 @@ empth_wait_for_signal(void)
return 0;
}
/************************
* empth_sem_create
*
* Create a signalling semaphore.
*/
empth_sem_t *
empth_sem_create(char *name, int cnt)
{
empth_sem_t *pSem;
pSem = malloc(sizeof(*pSem));
if (!pSem) {
logerror("out of memory at %s:%d", __FILE__, __LINE__);
return NULL;
}
memset(pSem, 0, sizeof(pSem));
strncpy(pSem->szName, name, sizeof(pSem->szName) - 1);
pSem->hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
pSem->count = cnt;
return pSem;
}
/************************
* empth_sem_signal
*
* Hit/signal the specified semaphore.
*/
void
empth_sem_signal(empth_sem_t *pSem)
{
loc_debug("signal on semaphore %s:%d", pSem->szName, pSem->count);
if (pSem->count++ < 0) {
SetEvent(pSem->hEvent);
}
}
/************************
* empth_sem_wait
*
* Wait for the specified signal semaphore to be signaled.
*/
void
empth_sem_wait(empth_sem_t *pSem)
{
empth_t *pThread = TlsGetValue(dwTLSIndex);
loc_debug("wait on semaphore %s:%d", pSem->szName, pSem->count);
if (--pSem->count < 0) {
/* Remove the thread from the running state. */
loc_BlockThisThread();
loc_debug("blocking");
loc_RunThisThread(pSem->hEvent);
loc_debug("waking up");
}
}
empth_rwlock_t *
empth_rwlock_create(char *name)
{

View file

@ -68,14 +68,6 @@ struct empth_t {
pthread_t id; /* thread id */
};
struct empth_sem_t {
pthread_mutex_t mtx_update; /* use it to update count */
int count;
char name[80];
pthread_mutex_t mtx_sem;
pthread_cond_t cnd_sem;
};
struct empth_rwlock_t {
char *name;
pthread_rwlock_t lock;
@ -415,57 +407,6 @@ empth_wait_for_signal(void)
}
}
empth_sem_t *
empth_sem_create(char *name, int cnt)
{
empth_sem_t *sm;
sm = malloc(sizeof(empth_sem_t));
if (!sm) {
logerror("out of memory at %s:%d", __FILE__, __LINE__);
return NULL;
}
strncpy(sm->name, name, sizeof(sm->name) - 1);
sm->count = cnt;
pthread_mutex_init(&sm->mtx_update, NULL);
pthread_mutex_init(&sm->mtx_sem, NULL);
pthread_cond_init(&sm->cnd_sem, NULL);
return sm;
}
void
empth_sem_signal(empth_sem_t *sm)
{
empth_status("signal on semaphore %s:%d", sm->name, sm->count);
pthread_mutex_lock(&sm->mtx_update);
if (sm->count++ < 0) {
pthread_mutex_unlock(&sm->mtx_update);
pthread_mutex_lock(&sm->mtx_sem);
pthread_cond_signal(&sm->cnd_sem);
pthread_mutex_unlock(&sm->mtx_sem);
} else
pthread_mutex_unlock(&sm->mtx_update);
}
void
empth_sem_wait(empth_sem_t *sm)
{
empth_status("wait on semaphore %s:%d", sm->name, sm->count);
pthread_mutex_lock(&sm->mtx_update);
if (--sm->count < 0) {
pthread_mutex_unlock(&sm->mtx_update);
empth_status("blocking");
pthread_mutex_unlock(&mtx_ctxsw);
pthread_mutex_lock(&sm->mtx_sem);
pthread_cond_wait(&sm->cnd_sem, &sm->mtx_sem);
empth_status("waking up");
pthread_mutex_unlock(&sm->mtx_sem);
pthread_mutex_lock(&mtx_ctxsw);
empth_restorectx();
} else
pthread_mutex_unlock(&sm->mtx_update);
}
empth_rwlock_t *
empth_rwlock_create(char *name)
{