pthread_cond_wait(&old_cpptr->c, &ct_mutex); pthread_mutex_unlock(&ct_mutex);
LWP_INT_WAIT(&old_cpptr->c, &ct_mutex); LWP_INT_UNLOCK(&ct_mutex); Debug(0, ("WaitProcess:%s woke up \n", old_cpptr->name))
LWP_MwaitProcess(int wcount, char *evlist[]) /* wait on m of n events */{    register int ecount, i;    PROCESS  old_cpptr;    Debug(0, ("Entered Mwait_Process [waitcnt = %d]", wcount));    if (evlist == NULL) {		Dispatcher();	return LWP_EBADCOUNT;    }	    /* count # of events in eventlist */    for (ecount = 0; evlist[ecount] != NULL; ecount++) ;    if (ecount == 0) {	Dispatcher();        return LWP_EBADCOUNT;    }    if (lwp_init) {        /* check for illegal counts */        if (wcount>ecount || wcount<0) {            Dispatcher();            return LWP_EBADCOUNT;	}        /* reallocate eventlist if new list has more elements than before */        if (ecount > lwp_cpptr->eventlistsize) {            lwp_cpptr->eventlist = 	      (char **)realloc((char *)lwp_cpptr->eventlist, 			       ecount*sizeof(char *));            lwp_cpptr->eventlistsize = ecount;	}        /* place events in eventlist of the pcb */        for (i=0; i<ecount; i++) lwp_cpptr -> eventlist[i] = evlist[i];        /* if there are any events to wait on then set status to           WAITING and place the pcb in blocked queue */        if (wcount > 0) {            lwp_cpptr -> status = WAITING;            lwpinsert(lwp_cpptr, &blocked);	}        lwp_cpptr -> wakevent = 0;      /* index of eventid causing wakeup */        lwp_cpptr -> waitcnt  = wcount;        lwp_cpptr -> eventcnt = ecount;	if (runnable[lwp_cpptr->priority].count == 0)	  Cal_Highest_runnable_priority();        old_cpptr = lwp_cpptr;        /* wake up next lwp */        lwp_cpptr = runnable[Highest_runnable_priority].head;        lwpremove(lwp_cpptr, &runnable[Highest_runnable_priority]);	timerclear(&lwp_cpptr->lastReady);	Debug(0, ("WaitProcess: %s Going to signal %s \n", 		  old_cpptr->name, lwp_cpptr->name))        pthread_mutex_lock(&ct_mutex);        pthread_cond_signal(&lwp_cpptr->c);	/* sleep on your own condition */	Debug(0, ("WaitProcess:%s going to wait \n", old_cpptr->name))	pthread_cond_wait(&old_cpptr->c, &ct_mutex);	pthread_mutex_unlock(&ct_mutex);	/* update the global pointer */	lwp_cpptr = old_cpptr;	if (lwp_cpptr->priority < Highest_runnable_priority)	    Dispatcher();	return LWP_SUCCESS ;    }    return LWP_EINIT ;}