|
|
1.1 root 1: #ifndef __KERNEL_V_PROC_H__
2: #define __KERNEL_V_PROC_H__
3:
4: /*
5: * This function describes a high-level abstract interface to the low-level
6: * scheduling system that is suitable for multiprocessor use. The design of
7: * this interface has been primarily motivated by the multiprocessor DDI/DKI
8: * sleep lock and synchronization variable functions, which impose a rather
9: * different model of sleep incompatible with the old-style sleep () and
10: * wakeup () functions. See "ksynch.c" for a detailed discussion of this.
11: *
12: * This interface is private to this DDI/DKI implementation, and is not
13: * part of the DDI/DKI itself. Portable code should not rely on the contents
14: * of this header at all.
15: */
16:
17: /*
18: *-IMPORTS:
19: * <common/ccompat.h>
20: * __EXTERN_C_BEGIN__
21: * __EXTERN_C_END__
22: * __PROTO ()
23: * <kernel/_sleep.h>
24: * __sleep_t
25: * <kernel/ddi_proc.h>
26: * pnode_t
27: * ddi_proc_data ()
28: */
29:
30: #include <common/ccompat.h>
31: #include <kernel/_sleep.h>
32: #include <kernel/ddi_proc.h>
33:
34:
35: /*
36: * Flag values to pass to MAKE_SLEEPING ().
37: */
38:
39: enum {
40: SLEEP_NO_SIGNALS,
41: SLEEP_INTERRUPTIBLE
42: };
43:
44:
45: /*
46: * The following structure type defines the information that a client of
47: * MAKE_SLEEPING is required to keep.
48: *
49: * If the underlying implementation uses an adress-based hash-list like the
50: * old-style sleep () and wakeup () functions, then this item need not contain
51: * any data. However, making at least one byte in size gives the property that
52: * the address of such an item is unique. While this would normally contain
53: * pointers threading process-table entries together, an implementation based
54: * on old-style broadcast wakeup is plausible (where this structure would
55: * contain counters to implement the one-at-a-time wakeup).
56: *
57: * Since this stuff is used to implement sleep locking, it is justified in not
58: * using basic locks but going instead to the really primitive operations.
59: */
60:
61: typedef struct proc_list plist_t;
62:
63: struct proc_list {
64: atomic_uchar_t pl_locked; /* control list manipulation */
65: pnode_t * pl_head; /* first waiting process info */
66: };
67:
68:
69: #define PLIST_INIT(l) ((void) ATOMIC_CLEAR_UCHAR ((l)->pl_locked))
70: #define PLIST_DESTROY(l) ((void) 0)
71: #define PLIST_LOCK(l,n) (TEST_AND_SET_LOCK ((l)->pl_locked, plhi, \
72: (n)))
73: #define PLIST_UNLOCK(l,p) (ATOMIC_CLEAR_UCHAR ((l)->pl_locked), \
74: (void) splx (p))
75: #define PLIST_ASSERT_LOCKED(l) ASSERT (ATOMIC_FETCH_UCHAR ((l)->pl_locked) \
76: != 0)
77:
78:
79: /*
80: * External function definitions. The curious may like to note that the use
81: * of the __PROTO () macro below has a useful side-effect with respect to
82: * macro-expansion of MAKE_SLEEPING (). The ISO C preprocessor scanning rules
83: * prevent MAKE_SLEEPING () below being expanded because the next right token
84: * is not a left parenthesis. The rescanning rules mean that even through
85: * __PROTO () actually expands to something beginning with a left parenthesis,
86: * the MAKE_SLEEPING token will get copied to the output without expansion,
87: * because it will not be considered again.
88: *
89: * This feature may be of some use if one has a non-ISO C compiler but can
90: * get the source ISO-preprocessed. Many K&R compilers do not understand the
91: * ISO macro-suppression idiom of enclosing a macro name within parentheses
92: * (this suppresses macro-expansion because the next token will be a right
93: * parenthesis) in function declarations due to weaknesses in the grammars
94: * used. Use of an identity macro to enclose the parameter list ensures that
95: * the preprocessor doesn't perform the expansion but leaves the function
96: * name unadorned by unnecessary parentheses. Note that enclosing the function
97: * name does not have the suppressing effect!
98: */
99:
100: __EXTERN_C_BEGIN__
101:
102: __sleep_t MAKE_SLEEPING __PROTO ((plist_t * _plistp, int _priority,
103: int _flag));
104: void RUN_NEXT __PROTO ((void));
105: __VOID__ * WAKE_ONE __PROTO ((plist_t * _plistp));
106: void WAKE_ALL __PROTO ((plist_t * _plistp));
107:
108: __VOID__ * PROC_HANDLE __PROTO ((void));
109:
110: __EXTERN_C_END__
111:
112:
113: #endif /* ! defined (__KERNEL_V_PROC_H__) */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.