scoutos / prex-0.9.0 / sys / include / sched.h @ 03e9c04a
History | View | Annotate | Download (2.95 KB)
1 |
/*-
|
---|---|
2 |
* Copyright (c) 2005-2007, Kohsuke Ohtani
|
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
|
9 |
* notice, this list of conditions and the following disclaimer.
|
10 |
* 2. Redistributions in binary form must reproduce the above copyright
|
11 |
* notice, this list of conditions and the following disclaimer in the
|
12 |
* documentation and/or other materials provided with the distribution.
|
13 |
* 3. Neither the name of the author nor the names of any co-contributors
|
14 |
* may be used to endorse or promote products derived from this software
|
15 |
* without specific prior written permission.
|
16 |
*
|
17 |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
18 |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
19 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
20 |
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
21 |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
22 |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
23 |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
24 |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
25 |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
26 |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
27 |
* SUCH DAMAGE.
|
28 |
*/
|
29 |
|
30 |
#ifndef _SCHED_H
|
31 |
#define _SCHED_H
|
32 |
|
33 |
#include <types.h> |
34 |
#include <sys/cdefs.h> |
35 |
#include <sys/queue.h> |
36 |
#include <event.h> |
37 |
|
38 |
/*
|
39 |
* Scheduling policies defined by IEEE Std 1003.1-2001
|
40 |
*/
|
41 |
#define SCHED_FIFO 0 /* First in-first out */ |
42 |
#define SCHED_RR 1 /* Round robin */ |
43 |
#define SCHED_OTHER 2 /* Another scheduling policy */ |
44 |
|
45 |
/*
|
46 |
* Scheduling quantum (Ticks for context switch)
|
47 |
*/
|
48 |
#define QUANTUM (CONFIG_TIME_SLICE * HZ / 1000) |
49 |
|
50 |
/*
|
51 |
* DPC (Deferred Procedure Call) object
|
52 |
*/
|
53 |
struct dpc {
|
54 |
struct queue link; /* linkage on DPC queue */ |
55 |
int state;
|
56 |
void (*func)(void *); /* callback routine */ |
57 |
void *arg; /* argument to pass */ |
58 |
}; |
59 |
|
60 |
/* state for DPC */
|
61 |
#define DPC_FREE 0x4470463f /* magic# 'DpF?' */ |
62 |
#define DPC_PENDING 0x4470503f /* magic# 'DpP?' */ |
63 |
|
64 |
#define sched_sleep(evt) sched_tsleep((evt), 0) |
65 |
|
66 |
__BEGIN_DECLS |
67 |
int sched_tsleep(struct event *, u_long); |
68 |
void sched_wakeup(struct event *); |
69 |
thread_t sched_wakeone(struct event *);
|
70 |
void sched_unsleep(thread_t, int); |
71 |
void sched_yield(void); |
72 |
void sched_suspend(thread_t);
|
73 |
void sched_resume(thread_t);
|
74 |
void sched_tick(void); |
75 |
void sched_start(thread_t, int, int); |
76 |
void sched_stop(thread_t);
|
77 |
void sched_lock(void); |
78 |
void sched_unlock(void); |
79 |
int sched_getpri(thread_t);
|
80 |
void sched_setpri(thread_t, int, int); |
81 |
int sched_getpolicy(thread_t);
|
82 |
int sched_setpolicy(thread_t, int); |
83 |
void sched_dpc(struct dpc *, void (*)(void *), void *); |
84 |
void sched_init(void); |
85 |
__END_DECLS |
86 |
|
87 |
#endif /* !_SCHED_H */ |