3 #include <machine/archtypes.h>
4 #include <minix/timers.h>
7 #include "kernel/config.h"
8 #include "kernel/const.h"
9 #include "kernel/type.h"
10 #include "kernel/proc.h"
12 /*===========================================================================*
14 *===========================================================================*/
15 int sched_inherit(endpoint_t scheduler_e
,
16 endpoint_t schedulee_e
, endpoint_t parent_e
, unsigned maxprio
,
17 endpoint_t
*newscheduler_e
)
22 assert(_ENDPOINT_P(scheduler_e
) >= 0);
23 assert(_ENDPOINT_P(schedulee_e
) >= 0);
24 assert(_ENDPOINT_P(parent_e
) >= 0);
25 assert(maxprio
< NR_SCHED_QUEUES
);
26 assert(newscheduler_e
);
28 memset(&m
, 0, sizeof(m
));
29 m
.SCHEDULING_ENDPOINT
= schedulee_e
;
30 m
.SCHEDULING_PARENT
= parent_e
;
31 m
.SCHEDULING_MAXPRIO
= (int) maxprio
;
33 /* Send the request to the scheduler */
34 if ((rv
= _taskcall(scheduler_e
, SCHEDULING_INHERIT
, &m
))) {
38 /* Store the process' scheduler. Note that this might not be the
39 * scheduler we sent the SCHEDULING_INHERIT message to. That scheduler
40 * might have forwarded the scheduling message on to another scheduler
41 * before returning the message.
43 *newscheduler_e
= m
.SCHEDULING_SCHEDULER
;
47 /*===========================================================================*
49 *===========================================================================*/
50 int sched_start(endpoint_t scheduler_e
,
51 endpoint_t schedulee_e
,
56 endpoint_t
*newscheduler_e
)
61 /* No scheduler given? We are done. */
62 if(scheduler_e
== NONE
) {
66 assert(_ENDPOINT_P(schedulee_e
) >= 0);
67 assert(_ENDPOINT_P(parent_e
) >= 0);
69 assert(maxprio
< NR_SCHED_QUEUES
);
71 assert(newscheduler_e
);
73 /* The KERNEL must schedule this process. */
74 if(scheduler_e
== KERNEL
) {
75 if ((rv
= sys_schedctl(SCHEDCTL_FLAG_KERNEL
,
76 schedulee_e
, maxprio
, quantum
, cpu
)) != OK
) {
79 *newscheduler_e
= scheduler_e
;
83 /* A user-space scheduler must schedule this process. */
84 memset(&m
, 0, sizeof(m
));
85 m
.SCHEDULING_ENDPOINT
= schedulee_e
;
86 m
.SCHEDULING_PARENT
= parent_e
;
87 m
.SCHEDULING_MAXPRIO
= (int) maxprio
;
88 m
.SCHEDULING_QUANTUM
= (int) quantum
;
90 /* Send the request to the scheduler */
91 if ((rv
= _taskcall(scheduler_e
, SCHEDULING_START
, &m
))) {
95 /* Store the process' scheduler. Note that this might not be the
96 * scheduler we sent the SCHEDULING_START message to. That scheduler
97 * might have forwarded the scheduling message on to another scheduler
98 * before returning the message.
100 *newscheduler_e
= m
.SCHEDULING_SCHEDULER
;