aboutsummaryrefslogtreecommitdiff
path: root/doc/chopstx-api.texi
blob: 65f8a710726d0b6b1455f8d35716c00e839ac263 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
@subheading chx_fatal
@anchor{chx_fatal}
@deftypefun {void} {chx_fatal} (uint32_t @var{err_code})
@var{err_code}: Error code

When it detects a coding error, this function will be called to
stop further execution of code.  It never returns.
@end deftypefun

@subheading chopstx_main_init
@anchor{chopstx_main_init}
@deftypefun {void} {chopstx_main_init} (chopstx_prio_t @var{prio})
@var{prio}: priority

Initialize main thread with @var{prio}.
The thread main is created with priority CHX_PRIO_MAIN_INIT,
and it runs with that priority until this routine will is called.
@end deftypefun

@subheading chopstx_create
@anchor{chopstx_create}
@deftypefun {chopstx_t} {chopstx_create} (uint32_t @var{flags_and_prio}, uint32_t @var{stack_addr}, size_t @var{stack_size}, voidfunc @var{thread_entry}, void * @var{arg})
@var{flags_and_prio}: Flags and priority

@var{stack_addr}: Stack address

@var{stack_size}: Size of stack

@var{thread_entry}: Entry function of new thread

@var{arg}: Argument to the thread entry function

Create a thread.  Returns thread ID.
@end deftypefun

@subheading chopstx_usec_wait_var
@anchor{chopstx_usec_wait_var}
@deftypefun {void} {chopstx_usec_wait_var} (uint32_t * @var{var})
@var{var}: Pointer to usec

Sleep for micro seconds, specified by @var{var}.
Another thread can clear @var{var} to stop the caller going into sleep.
@end deftypefun

@subheading chopstx_usec_wait
@anchor{chopstx_usec_wait}
@deftypefun {void} {chopstx_usec_wait} (uint32_t @var{usec})
@var{usec}: number of micro seconds

Sleep for @var{usec}.
@end deftypefun

@subheading chopstx_mutex_init
@anchor{chopstx_mutex_init}
@deftypefun {void} {chopstx_mutex_init} (chopstx_mutex_t * @var{mutex})
@var{mutex}: Mutex

Initialize @var{mutex}.
@end deftypefun

@subheading chopstx_mutex_lock
@anchor{chopstx_mutex_lock}
@deftypefun {void} {chopstx_mutex_lock} (chopstx_mutex_t * @var{mutex})
@var{mutex}: Mutex

Lock @var{mutex}.
@end deftypefun

@subheading chopstx_mutex_unlock
@anchor{chopstx_mutex_unlock}
@deftypefun {void} {chopstx_mutex_unlock} (chopstx_mutex_t * @var{mutex})
@var{mutex}: Mutex

Unlock @var{mutex}.
@end deftypefun

@subheading chopstx_cond_init
@anchor{chopstx_cond_init}
@deftypefun {void} {chopstx_cond_init} (chopstx_cond_t * @var{cond})
@var{cond}: Condition variable

Initialize @var{cond}.
@end deftypefun

@subheading chopstx_cond_wait
@anchor{chopstx_cond_wait}
@deftypefun {void} {chopstx_cond_wait} (chopstx_cond_t * @var{cond}, chopstx_mutex_t * @var{mutex})
@var{cond}: Condition variable

@var{mutex}: Associated mutex

Wait for @var{cond} with @var{mutex}.
@end deftypefun

@subheading chopstx_cond_signal
@anchor{chopstx_cond_signal}
@deftypefun {void} {chopstx_cond_signal} (chopstx_cond_t * @var{cond})
@var{cond}: Condition variable

Wake up a thread waiting on @var{cond}.
@end deftypefun

@subheading chopstx_cond_broadcast
@anchor{chopstx_cond_broadcast}
@deftypefun {void} {chopstx_cond_broadcast} (chopstx_cond_t * @var{cond})
@var{cond}: Condition Variable

Wake up all threads waiting on @var{cond}.
@end deftypefun

@subheading chopstx_claim_irq
@anchor{chopstx_claim_irq}
@deftypefun {void} {chopstx_claim_irq} (chopstx_intr_t * @var{intr}, uint8_t @var{irq_num})
@var{intr}: Pointer to INTR structure

@var{irq_num}: IRQ Number (hardware specific)

Claim interrupt @var{intr} with @var{irq_num} for this thread.
@end deftypefun

@subheading chopstx_intr_wait
@anchor{chopstx_intr_wait}
@deftypefun {void} {chopstx_intr_wait} (chopstx_intr_t * @var{intr})
@var{intr}: Pointer to INTR structure

Wait for the interrupt @var{intr} to be occured.

This function is DEPRECATED.  Use chopstx_poll.
@end deftypefun

@subheading chopstx_cleanup_push
@anchor{chopstx_cleanup_push}
@deftypefun {void} {chopstx_cleanup_push} (struct chx_cleanup * @var{clp})
@var{clp}: Pointer to clean-up structure

Register a clean-up structure.
@end deftypefun

@subheading chopstx_cleanup_pop
@anchor{chopstx_cleanup_pop}
@deftypefun {void} {chopstx_cleanup_pop} (int @var{execute})
@var{execute}: Execute the clen-up function on release

Unregister a clean-up structure.  When @var{execute} is non-zero, the
clean-up will be executed.
@end deftypefun

@subheading chopstx_exit
@anchor{chopstx_exit}
@deftypefun {void} {chopstx_exit} (void * @var{retval})
@var{retval}: Return value (to be caught by a joining thread)

Calling this function terminates the execution of thread, after
calling clean up functions.  If the calling thread still holds
mutexes, they will be released.  If the calling thread claiming
IRQ, it will be released, too.  This function never returns.
@end deftypefun

@subheading chopstx_join
@anchor{chopstx_join}
@deftypefun {void} {chopstx_join} (chopstx_t @var{thd}, void ** @var{ret})
@var{thd}: Thread to wait

@var{ret}: Pointer to void * to store return value

Waits for the thread of @var{thd} to terminate.
@end deftypefun

@subheading chopstx_wakeup_usec_wait
@anchor{chopstx_wakeup_usec_wait}
@deftypefun {void} {chopstx_wakeup_usec_wait} (chopstx_t @var{thd})
@var{thd}: Thread to be awakened

Canceling the timer, wake up the sleeping thread.
No return value.
@end deftypefun

@subheading chopstx_cancel
@anchor{chopstx_cancel}
@deftypefun {void} {chopstx_cancel} (chopstx_t @var{thd})
@var{thd}: Thread to be canceled

This function requests a cancellation of a thread @var{thd}.
No return value.
@end deftypefun

@subheading chopstx_testcancel
@anchor{chopstx_testcancel}
@deftypefun {void} {chopstx_testcancel} ( @var{void})

Calling chopstx_testcancel creates a cancellation point.
No return value.  If the thread is canceled, this function
does not return.
@end deftypefun

@subheading chopstx_setcancelstate
@anchor{chopstx_setcancelstate}
@deftypefun {int} {chopstx_setcancelstate} (int @var{cancel_disable})
@var{cancel_disable}: 0 to enable cancelation, otherwise disabled.

Calling chopstx_setcancelstate sets cancelability state.

Returns old state which is 0 when it was enabled.
@end deftypefun

@subheading chopstx_poll
@anchor{chopstx_poll}
@deftypefun {int} {chopstx_poll} (uint32_t * @var{usec_p}, int @var{n},  @var{...})
@var{usec_p}: Pointer to usec for timeout.  Forever if NULL.

@var{n}: Number of poll descriptors

Returns number of active descriptors.
@end deftypefun