4 * Implement the MP lock. Note that debug operations
6 #ifndef _SYS_MPLOCK2_H_
7 #define _SYS_MPLOCK2_H_
9 #ifndef _MACHINE_ATOMIC_H_
10 #include <machine/atomic.h>
12 #ifndef _SYS_THREAD_H_
13 #include <sys/thread.h>
15 #ifndef _SYS_GLOBALDATA_H_
16 #include <sys/globaldata.h>
22 * NOTE: try_mplock()/lwkt_trytoken() return non-zero on success.
24 #define get_mplock() lwkt_gettoken(&mp_token)
25 #define try_mplock() lwkt_trytoken(&mp_token)
26 #define rel_mplock() lwkt_reltoken(&mp_token)
27 #define get_mplock_count(td) lwkt_cnttoken(&mp_token, td)
29 void cpu_get_initial_mplock(void);
30 void handle_cpu_contention_mask(void);
32 extern cpumask_t cpu_contention_mask;
35 * A cpu wanted the MP lock but could not get it. This function is also
36 * called directly from the LWKT scheduler.
38 * Reentrant, may be called even if the cpu is already contending the MP
43 set_cpu_contention_mask(globaldata_t gd)
45 atomic_set_cpumask(&cpu_contention_mask, gd->gd_cpumask);
49 * A cpu is no longer contending for the MP lock after previously contending
52 * Reentrant, may be called even if the cpu was not previously contending
57 clr_cpu_contention_mask(globaldata_t gd)
59 atomic_clear_cpumask(&cpu_contention_mask, gd->gd_cpumask);
62 #define MP_LOCK_HELD() LWKT_TOKEN_HELD(&mp_token)
63 #define ASSERT_MP_LOCK_HELD() ASSERT_LWKT_TOKEN_HELD(&mp_token)
69 * UNI-PROCESSOR BUILD - Degenerate case macros
73 #define try_mplock() 1
74 #define owner_mplock() 0
75 #define MP_LOCK_HELD(gd) 1
76 #define ASSERT_MP_LOCK_HELD(td)