Deleted Added
full compact
thr_mutex.c (149298) thr_mutex.c (155962)
1/*
2 * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 15 unchanged lines hidden (view full) ---

24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 *
1/*
2 * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 15 unchanged lines hidden (view full) ---

24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 *
32 * $FreeBSD: head/lib/libkse/thread/thr_mutex.c 149298 2005-08-19 21:31:42Z stefanf $
32 * $FreeBSD: head/lib/libkse/thread/thr_mutex.c 155962 2006-02-23 21:34:08Z deischen $
33 */
34#include <stdlib.h>
35#include <errno.h>
36#include <string.h>
37#include <sys/param.h>
38#include <sys/queue.h>
39#include <pthread.h>
40#include "thr_private.h"

--- 505 unchanged lines hidden (view full) ---

546 /* Unlock the mutex structure: */
547 THR_LOCK_RELEASE(curthread, &(*m)->m_lock);
548 } else if ((*m)->m_owner == curthread) {
549 ret = mutex_self_lock(curthread, *m);
550
551 /* Unlock the mutex structure: */
552 THR_LOCK_RELEASE(curthread, &(*m)->m_lock);
553 } else {
33 */
34#include <stdlib.h>
35#include <errno.h>
36#include <string.h>
37#include <sys/param.h>
38#include <sys/queue.h>
39#include <pthread.h>
40#include "thr_private.h"

--- 505 unchanged lines hidden (view full) ---

546 /* Unlock the mutex structure: */
547 THR_LOCK_RELEASE(curthread, &(*m)->m_lock);
548 } else if ((*m)->m_owner == curthread) {
549 ret = mutex_self_lock(curthread, *m);
550
551 /* Unlock the mutex structure: */
552 THR_LOCK_RELEASE(curthread, &(*m)->m_lock);
553 } else {
554 /* Set the wakeup time: */
555 if (abstime) {
556 curthread->wakeup_time.tv_sec =
557 abstime->tv_sec;
558 curthread->wakeup_time.tv_nsec =
559 abstime->tv_nsec;
560 }
561
562 /*
563 * Join the queue of threads waiting to lock
564 * the mutex and save a pointer to the mutex.
565 */
566 mutex_queue_enq(*m, curthread);
567 curthread->data.mutex = *m;
568 curthread->sigbackout = mutex_lock_backout;
569 /*
570 * This thread is active and is in a critical
571 * region (holding the mutex lock); we should
572 * be able to safely set the state.
573 */
574 THR_SCHED_LOCK(curthread, curthread);
554 /*
555 * Join the queue of threads waiting to lock
556 * the mutex and save a pointer to the mutex.
557 */
558 mutex_queue_enq(*m, curthread);
559 curthread->data.mutex = *m;
560 curthread->sigbackout = mutex_lock_backout;
561 /*
562 * This thread is active and is in a critical
563 * region (holding the mutex lock); we should
564 * be able to safely set the state.
565 */
566 THR_SCHED_LOCK(curthread, curthread);
567 /* Set the wakeup time: */
568 if (abstime) {
569 curthread->wakeup_time.tv_sec =
570 abstime->tv_sec;
571 curthread->wakeup_time.tv_nsec =
572 abstime->tv_nsec;
573 }
574
575 THR_SET_STATE(curthread, PS_MUTEX_WAIT);
576 THR_SCHED_UNLOCK(curthread, curthread);
577
578 /* Unlock the mutex structure: */
579 THR_LOCK_RELEASE(curthread, &(*m)->m_lock);
580
581 /* Schedule the next thread: */
582 _thr_sched_switch(curthread);

--- 45 unchanged lines hidden (view full) ---

628 /* Unlock the mutex structure: */
629 THR_LOCK_RELEASE(curthread, &(*m)->m_lock);
630 } else if ((*m)->m_owner == curthread) {
631 ret = mutex_self_lock(curthread, *m);
632
633 /* Unlock the mutex structure: */
634 THR_LOCK_RELEASE(curthread, &(*m)->m_lock);
635 } else {
575 THR_SET_STATE(curthread, PS_MUTEX_WAIT);
576 THR_SCHED_UNLOCK(curthread, curthread);
577
578 /* Unlock the mutex structure: */
579 THR_LOCK_RELEASE(curthread, &(*m)->m_lock);
580
581 /* Schedule the next thread: */
582 _thr_sched_switch(curthread);

--- 45 unchanged lines hidden (view full) ---

628 /* Unlock the mutex structure: */
629 THR_LOCK_RELEASE(curthread, &(*m)->m_lock);
630 } else if ((*m)->m_owner == curthread) {
631 ret = mutex_self_lock(curthread, *m);
632
633 /* Unlock the mutex structure: */
634 THR_LOCK_RELEASE(curthread, &(*m)->m_lock);
635 } else {
636 /* Set the wakeup time: */
637 if (abstime) {
638 curthread->wakeup_time.tv_sec =
639 abstime->tv_sec;
640 curthread->wakeup_time.tv_nsec =
641 abstime->tv_nsec;
642 }
643
644 /*
645 * Join the queue of threads waiting to lock
646 * the mutex and save a pointer to the mutex.
647 */
648 mutex_queue_enq(*m, curthread);
649 curthread->data.mutex = *m;
650 curthread->sigbackout = mutex_lock_backout;
651
652 /*
653 * This thread is active and is in a critical
654 * region (holding the mutex lock); we should
655 * be able to safely set the state.
656 */
657 if (curthread->active_priority > (*m)->m_prio)
658 /* Adjust priorities: */
659 mutex_priority_adjust(curthread, *m);
660
661 THR_SCHED_LOCK(curthread, curthread);
636 /*
637 * Join the queue of threads waiting to lock
638 * the mutex and save a pointer to the mutex.
639 */
640 mutex_queue_enq(*m, curthread);
641 curthread->data.mutex = *m;
642 curthread->sigbackout = mutex_lock_backout;
643
644 /*
645 * This thread is active and is in a critical
646 * region (holding the mutex lock); we should
647 * be able to safely set the state.
648 */
649 if (curthread->active_priority > (*m)->m_prio)
650 /* Adjust priorities: */
651 mutex_priority_adjust(curthread, *m);
652
653 THR_SCHED_LOCK(curthread, curthread);
654 /* Set the wakeup time: */
655 if (abstime) {
656 curthread->wakeup_time.tv_sec =
657 abstime->tv_sec;
658 curthread->wakeup_time.tv_nsec =
659 abstime->tv_nsec;
660 }
662 THR_SET_STATE(curthread, PS_MUTEX_WAIT);
663 THR_SCHED_UNLOCK(curthread, curthread);
664
665 /* Unlock the mutex structure: */
666 THR_LOCK_RELEASE(curthread, &(*m)->m_lock);
667
668 /* Schedule the next thread: */
669 _thr_sched_switch(curthread);

--- 55 unchanged lines hidden (view full) ---

725 /* Unlock the mutex structure: */
726 THR_LOCK_RELEASE(curthread, &(*m)->m_lock);
727 } else if ((*m)->m_owner == curthread) {
728 ret = mutex_self_lock(curthread, *m);
729
730 /* Unlock the mutex structure: */
731 THR_LOCK_RELEASE(curthread, &(*m)->m_lock);
732 } else {
661 THR_SET_STATE(curthread, PS_MUTEX_WAIT);
662 THR_SCHED_UNLOCK(curthread, curthread);
663
664 /* Unlock the mutex structure: */
665 THR_LOCK_RELEASE(curthread, &(*m)->m_lock);
666
667 /* Schedule the next thread: */
668 _thr_sched_switch(curthread);

--- 55 unchanged lines hidden (view full) ---

724 /* Unlock the mutex structure: */
725 THR_LOCK_RELEASE(curthread, &(*m)->m_lock);
726 } else if ((*m)->m_owner == curthread) {
727 ret = mutex_self_lock(curthread, *m);
728
729 /* Unlock the mutex structure: */
730 THR_LOCK_RELEASE(curthread, &(*m)->m_lock);
731 } else {
733 /* Set the wakeup time: */
734 if (abstime) {
735 curthread->wakeup_time.tv_sec =
736 abstime->tv_sec;
737 curthread->wakeup_time.tv_nsec =
738 abstime->tv_nsec;
739 }
740
741 /*
742 * Join the queue of threads waiting to lock
743 * the mutex and save a pointer to the mutex.
744 */
745 mutex_queue_enq(*m, curthread);
746 curthread->data.mutex = *m;
747 curthread->sigbackout = mutex_lock_backout;
748
749 /* Clear any previous error: */
750 curthread->error = 0;
751
752 /*
753 * This thread is active and is in a critical
754 * region (holding the mutex lock); we should
755 * be able to safely set the state.
756 */
757
758 THR_SCHED_LOCK(curthread, curthread);
732 /*
733 * Join the queue of threads waiting to lock
734 * the mutex and save a pointer to the mutex.
735 */
736 mutex_queue_enq(*m, curthread);
737 curthread->data.mutex = *m;
738 curthread->sigbackout = mutex_lock_backout;
739
740 /* Clear any previous error: */
741 curthread->error = 0;
742
743 /*
744 * This thread is active and is in a critical
745 * region (holding the mutex lock); we should
746 * be able to safely set the state.
747 */
748
749 THR_SCHED_LOCK(curthread, curthread);
750 /* Set the wakeup time: */
751 if (abstime) {
752 curthread->wakeup_time.tv_sec =
753 abstime->tv_sec;
754 curthread->wakeup_time.tv_nsec =
755 abstime->tv_nsec;
756 }
759 THR_SET_STATE(curthread, PS_MUTEX_WAIT);
760 THR_SCHED_UNLOCK(curthread, curthread);
761
762 /* Unlock the mutex structure: */
763 THR_LOCK_RELEASE(curthread, &(*m)->m_lock);
764
765 /* Schedule the next thread: */
766 _thr_sched_switch(curthread);

--- 1051 unchanged lines hidden ---
757 THR_SET_STATE(curthread, PS_MUTEX_WAIT);
758 THR_SCHED_UNLOCK(curthread, curthread);
759
760 /* Unlock the mutex structure: */
761 THR_LOCK_RELEASE(curthread, &(*m)->m_lock);
762
763 /* Schedule the next thread: */
764 _thr_sched_switch(curthread);

--- 1051 unchanged lines hidden ---