3 #include <machine/archtypes.h>
6 #include "kernel/config.h"
7 #include "kernel/const.h"
8 #include "kernel/type.h"
9 #include "kernel/proc.h"
11 /*===========================================================================*
13 *===========================================================================*/
14 int sched_inherit(endpoint_t scheduler_e
,
15 endpoint_t schedulee_e
, endpoint_t parent_e
, unsigned maxprio
,
16 endpoint_t
*newscheduler_e
)
21 assert(_ENDPOINT_P(scheduler_e
) >= 0);
22 assert(_ENDPOINT_P(schedulee_e
) >= 0);
23 assert(_ENDPOINT_P(parent_e
) >= 0);
24 assert(maxprio
< NR_SCHED_QUEUES
);
25 assert(newscheduler_e
);
27 m
.SCHEDULING_ENDPOINT
= schedulee_e
;
28 m
.SCHEDULING_PARENT
= parent_e
;
29 m
.SCHEDULING_MAXPRIO
= (int) maxprio
;
31 /* Send the request to the scheduler */
32 if ((rv
= _taskcall(scheduler_e
, SCHEDULING_INHERIT
, &m
))) {
36 /* Store the process' scheduler. Note that this might not be the
37 * scheduler we sent the SCHEDULING_INHERIT message to. That scheduler
38 * might have forwarded the scheduling message on to another scheduler
39 * before returning the message.
41 *newscheduler_e
= m
.SCHEDULING_SCHEDULER
;
45 /*===========================================================================*
47 *===========================================================================*/
48 int sched_start(endpoint_t scheduler_e
,
49 endpoint_t schedulee_e
,
54 endpoint_t
*newscheduler_e
)
59 /* No scheduler given? We are done. */
60 if(scheduler_e
== NONE
) {
64 assert(_ENDPOINT_P(schedulee_e
) >= 0);
65 assert(_ENDPOINT_P(parent_e
) >= 0);
67 assert(maxprio
< NR_SCHED_QUEUES
);
69 assert(newscheduler_e
);
71 /* The KERNEL must schedule this process. */
72 if(scheduler_e
== KERNEL
) {
73 if ((rv
= sys_schedctl(SCHEDCTL_FLAG_KERNEL
,
74 schedulee_e
, maxprio
, quantum
, cpu
)) != OK
) {
77 *newscheduler_e
= scheduler_e
;
81 /* A user-space scheduler must schedule this process. */
82 m
.SCHEDULING_ENDPOINT
= schedulee_e
;
83 m
.SCHEDULING_PARENT
= parent_e
;
84 m
.SCHEDULING_MAXPRIO
= (int) maxprio
;
85 m
.SCHEDULING_QUANTUM
= (int) quantum
;
87 /* Send the request to the scheduler */
88 if ((rv
= _taskcall(scheduler_e
, SCHEDULING_START
, &m
))) {
92 /* Store the process' scheduler. Note that this might not be the
93 * scheduler we sent the SCHEDULING_START message to. That scheduler
94 * might have forwarded the scheduling message on to another scheduler
95 * before returning the message.
97 *newscheduler_e
= m
.SCHEDULING_SCHEDULER
;