Branch: Tag:

1998-01-03

1998-01-03 07:13:06 by Fredrik Hübinette (Hubbe) <hubbe@hubbe.net>

now works better with NT

Rev: NT/tools/lib:1.3
Rev: bin/test_pike.pike:1.5
Rev: lib/modules/Stdio.pmod:1.7
Rev: src/fdlib.c:1.2
Rev: src/fdlib.h:1.2
Rev: src/modules/Image/font.c:1.24
Rev: src/modules/files/efuns.c:1.42
Rev: src/modules/files/file.c:1.64
Rev: src/modules/files/socket.c:1.21
Rev: src/modules/files/testsuite.in:1.7
Rev: src/port.c:1.14
Rev: src/testsuite.in:1.63
Rev: src/threads.c:1.50
Rev: src/threads.h:1.24

1:   #include "global.h" - RCSID("$Id: threads.c,v 1.49 1998/01/02 08:18:43 hubbe Exp $"); + RCSID("$Id: threads.c,v 1.50 1998/01/03 07:12:12 hubbe Exp $");      int num_threads = 1;   int threads_disabled = 0;
15:   #include "program.h"   #include "gc.h"    + #ifdef SIMULATE_COND_WITH_EVENT + int co_wait(COND_T *c, MUTEX_T *m) + { +  struct cond_t_queue me; +  event_init(&me.event); +  mt_lock(& c->lock); +  +  me.next=c->tail; +  c->tail=&me; +  if(!c->head) c->head=&me; +  +  mt_unlock(& c->lock); +  mt_unlock(m); +  event_wait(&me.event); +  mt_lock(m); +  +  event_destroy(& me.event); +  /* Cancellation point?? */ +  +  return 0; + } +  + int co_signal(COND_T *c) + { +  struct cond_t_queue *t; +  mt_lock(& c->lock); +  if(t=c->head) +  { +  c->head=t->next; +  t->next=0; +  if(!c->head) c->tail=0; +  } +  mt_unlock(& c->lock); +  if(t) +  event_signal(& t->event); +  return 0; + } +  + int co_broadcast(COND_T *c) + { +  struct cond_t_queue *t,*n; +  mt_lock(& c->lock); +  n=c->head; +  c->head=c->tail=0; +  mt_unlock(& c->lock); +  +  while((t=n)) +  { +  n=t->next; +  event_signal(& t->event); +  } +  +  return 0; + } +  + int co_destroy(COND_T *c) + { +  struct cond_t_queue *t; +  mt_lock(& c->lock); +  n=c->head; +  c->head=c->tail=0; +  if(t) return EBUSY; +  return 0; + } +  + #endif +  +    #define THIS_THREAD ((struct thread_state *)fp->current_storage)      struct object *thread_id;