fixed a locking issue

Original commit message from CVS:
fixed a locking issue
This commit is contained in:
Erik Walthinsen 2001-04-25 23:30:23 +00:00
parent 284bfca414
commit 7b28fc9215

View file

@ -133,6 +133,13 @@ cothread_create (cothread_context *ctx)
// is this needed anymore? // is this needed anymore?
s->top_sp = s->sp; s->top_sp = s->sp;
// initialize the lock
#ifdef COTHREAD_ATOMIC
atomic_set (s->lock, 0);
#else
s->lock = g_mutex_new();
#endif
GST_INFO (GST_CAT_COTHREADS,"created cothread #%d: %p at sp:%p", ctx->nthreads, s, s->sp); GST_INFO (GST_CAT_COTHREADS,"created cothread #%d: %p at sp:%p", ctx->nthreads, s, s->sp);
ctx->threads[ctx->nthreads++] = s; ctx->threads[ctx->nthreads++] = s;
@ -183,11 +190,11 @@ cothread_stub (void)
GST_DEBUG_ENTER(""); GST_DEBUG_ENTER("");
thread->flags |= COTHREAD_STARTED; thread->flags |= COTHREAD_STARTED;
#ifdef COTHREAD_ATOMIC //#ifdef COTHREAD_ATOMIC
// do something here to lock // // do something here to lock
#else //#else
g_mutex_lock(thread->lock); // g_mutex_lock(thread->lock);
#endif //#endif
while (1) { while (1) {
thread->func(thread->argc,thread->argv); thread->func(thread->argc,thread->argv);
// we do this to avoid ever returning, we just switch to 0th thread // we do this to avoid ever returning, we just switch to 0th thread