Date: Fri, 23 Oct 1998 21:50:01 -0700 (PDT) From: Daniel Eischen <eischen@vigrid.com> To: freebsd-bugs@FreeBSD.ORG Subject: Re: kern/8375: pthread_cond_wait() spins the CPU Message-ID: <199810240450.VAA11508@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR kern/8375; it has been noted by GNATS. From: Daniel Eischen <eischen@vigrid.com> To: dima@tejblum.dnttm.rssi.ru, eischen@vigrid.com Cc: freebsd-gnats-submit@FreeBSD.ORG, jb@FreeBSD.ORG Subject: Re: kern/8375: pthread_cond_wait() spins the CPU Date: Sat, 24 Oct 1998 00:46:23 -0400 (EDT) BTW, pthread_mutex_lock also has the same problem as pthread_cond_wait if thread scheduling comes at an inopportune time: _SPINLOCK(&(*mutex)->lock); /* Process according to mutex type: */ switch ((*mutex)->m_type) { /* Fast mutexes do not check for any error conditions: */ case MUTEX_TYPE_FAST: /* * Enter a loop to wait for the mutex to be locked by the * current thread: */ while ((*mutex)->m_owner != _thread_run) { /* Check if the mutex is not locked: */ if ((*mutex)->m_owner == NULL) { /* Lock the mutex for this thread: */ (*mutex)->m_owner = _thread_run; } else { /* * Join the queue of threads waiting to lock * the mutex: */ _thread_queue_enq(&(*mutex)->m_queue, _thread_run); /* Unlock the mutex structure: */ _SPINUNLOCK(&(*mutex)->lock); /* Block signals: */ _thread_kern_sched_state(PS_MUTEX_WAIT, __FILE__, __LINE__); If thread scheduling is kicked off right after the last SPINUNLOCK, then you can also have a thread removed from the mutex queue, but it'll never get woken up. Dan Eischen eischen@vigrid.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199810240450.VAA11508>