thr_mutex.c (6439d4c2866f4d9822ddb43789af19976ebce620) | thr_mutex.c (7d9d7ca2ed3e3d630e63482c41f2d26194129c2c) |
---|---|
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 --- 50 unchanged lines hidden (view full) --- 59#define _MUTEX_ASSERT_NOT_OWNED(m) 60#endif 61 62/* 63 * Prototypes 64 */ 65static int get_muncontested(pthread_mutex_t, int); 66static void get_mcontested(pthread_mutex_t); | 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 --- 50 unchanged lines hidden (view full) --- 59#define _MUTEX_ASSERT_NOT_OWNED(m) 60#endif 61 62/* 63 * Prototypes 64 */ 65static int get_muncontested(pthread_mutex_t, int); 66static void get_mcontested(pthread_mutex_t); |
67static int mutex_lock_common(pthread_mutex_t *, int); |
|
67static inline int mutex_self_trylock(pthread_mutex_t); 68static inline int mutex_self_lock(pthread_mutex_t); 69static inline int mutex_unlock_common(pthread_mutex_t *, int); 70static void mutex_priority_adjust(pthread_mutex_t); 71static void mutex_rescan_owned (pthread_t, pthread_mutex_t); 72static inline pthread_t mutex_queue_deq(pthread_mutex_t); 73static inline void mutex_queue_remove(pthread_mutex_t, pthread_t); 74static inline void mutex_queue_enq(pthread_mutex_t, pthread_t); --- 1301 unchanged lines hidden (view full) --- 1376 1377/* 1378 * Returns with the lock owned and on the threads mutexq if 1379 * it is currently unowned. Returns 1, otherwise. 1380 */ 1381static int 1382get_muncontested(pthread_mutex_t mutexp, int nonblock) 1383{ | 68static inline int mutex_self_trylock(pthread_mutex_t); 69static inline int mutex_self_lock(pthread_mutex_t); 70static inline int mutex_unlock_common(pthread_mutex_t *, int); 71static void mutex_priority_adjust(pthread_mutex_t); 72static void mutex_rescan_owned (pthread_t, pthread_mutex_t); 73static inline pthread_t mutex_queue_deq(pthread_mutex_t); 74static inline void mutex_queue_remove(pthread_mutex_t, pthread_t); 75static inline void mutex_queue_enq(pthread_mutex_t, pthread_t); --- 1301 unchanged lines hidden (view full) --- 1377 1378/* 1379 * Returns with the lock owned and on the threads mutexq if 1380 * it is currently unowned. Returns 1, otherwise. 1381 */ 1382static int 1383get_muncontested(pthread_mutex_t mutexp, int nonblock) 1384{ |
1384 if (mutexp->m_owner != NULL && mutexp->m_owner != curthread) | 1385 if (mutexp->m_owner != NULL && mutexp->m_owner != curthread) { |
1385 return (-1); | 1386 return (-1); |
1386 else if (mutexp->m_owner == curthread) | 1387 } else if (mutexp->m_owner == curthread) { |
1387 if (nonblock) 1388 return (mutex_self_trylock(mutexp)); 1389 else 1390 return (mutex_self_lock(mutexp)); | 1388 if (nonblock) 1389 return (mutex_self_trylock(mutexp)); 1390 else 1391 return (mutex_self_lock(mutexp)); |
1392 } |
|
1391 1392 /* 1393 * The mutex belongs to this thread now. Mark it as 1394 * such. Add it to the list of mutexes owned by this 1395 * thread. 1396 */ 1397 mutexp->m_owner = curthread; 1398 _MUTEX_ASSERT_NOT_OWNED(mutexp); --- 34 unchanged lines hidden --- | 1393 1394 /* 1395 * The mutex belongs to this thread now. Mark it as 1396 * such. Add it to the list of mutexes owned by this 1397 * thread. 1398 */ 1399 mutexp->m_owner = curthread; 1400 _MUTEX_ASSERT_NOT_OWNED(mutexp); --- 34 unchanged lines hidden --- |