0
|
1 |
/*
|
|
2 |
* $Id:$
|
|
3 |
* Generic version: no threads.
|
|
4 |
* by Wolfram Gloger 2004
|
|
5 |
*/
|
|
6 |
|
|
7 |
#include <stdio.h>
|
|
8 |
|
|
9 |
struct thread_st {
|
|
10 |
char *sp; /* stack pointer, can be 0 */
|
|
11 |
void (*func)(struct thread_st* st); /* must be set by user */
|
|
12 |
int id;
|
|
13 |
int flags;
|
|
14 |
struct user_data u;
|
|
15 |
};
|
|
16 |
|
|
17 |
static void
|
|
18 |
thread_init(void)
|
|
19 |
{
|
|
20 |
printf("No threads.\n");
|
|
21 |
}
|
|
22 |
|
|
23 |
/* Create a thread. */
|
|
24 |
static int
|
|
25 |
thread_create(struct thread_st *st)
|
|
26 |
{
|
|
27 |
st->flags = 0;
|
|
28 |
st->id = 1;
|
|
29 |
st->func(st);
|
|
30 |
return 0;
|
|
31 |
}
|
|
32 |
|
|
33 |
/* Wait for one of several subthreads to finish. */
|
|
34 |
static void
|
|
35 |
wait_for_thread(struct thread_st st[], int n_thr,
|
|
36 |
int (*end_thr)(struct thread_st*))
|
|
37 |
{
|
|
38 |
int i;
|
|
39 |
for(i=0; i<n_thr; i++)
|
|
40 |
if(end_thr)
|
|
41 |
end_thr(&st[i]);
|
|
42 |
}
|
|
43 |
|
|
44 |
/*
|
|
45 |
* Local variables:
|
|
46 |
* tab-width: 4
|
|
47 |
* End:
|
|
48 |
*/
|