3 #include <machine/archtypes.h>
4 #include <minix/timers.h>
5 #include <minix/sched.h>
8 /*===========================================================================*
10 *===========================================================================*/
11 int sched_inherit(endpoint_t scheduler_e
,
12 endpoint_t schedulee_e
, endpoint_t parent_e
, unsigned maxprio
,
13 endpoint_t
*newscheduler_e
)
18 assert(_ENDPOINT_P(scheduler_e
) >= 0);
19 assert(_ENDPOINT_P(schedulee_e
) >= 0);
20 assert(_ENDPOINT_P(parent_e
) >= 0);
21 assert(maxprio
< NR_SCHED_QUEUES
);
22 assert(newscheduler_e
);
24 memset(&m
, 0, sizeof(m
));
25 m
.m_lsys_sched_scheduling_start
.endpoint
= schedulee_e
;
26 m
.m_lsys_sched_scheduling_start
.parent
= parent_e
;
27 m
.m_lsys_sched_scheduling_start
.maxprio
= maxprio
;
29 /* Send the request to the scheduler */
30 if ((rv
= _taskcall(scheduler_e
, SCHEDULING_INHERIT
, &m
))) {
34 /* Store the process' scheduler. Note that this might not be the
35 * scheduler we sent the SCHEDULING_INHERIT message to. That scheduler
36 * might have forwarded the scheduling message on to another scheduler
37 * before returning the message.
39 *newscheduler_e
= m
.m_sched_lsys_scheduling_start
.scheduler
;
43 /*===========================================================================*
45 *===========================================================================*/
46 int sched_start(endpoint_t scheduler_e
,
47 endpoint_t schedulee_e
,
52 endpoint_t
*newscheduler_e
)
57 /* No scheduler given? We are done. */
58 if(scheduler_e
== NONE
) {
62 assert(_ENDPOINT_P(schedulee_e
) >= 0);
63 assert(_ENDPOINT_P(parent_e
) >= 0);
65 assert(maxprio
< NR_SCHED_QUEUES
);
67 assert(newscheduler_e
);
69 /* The KERNEL must schedule this process. */
70 if(scheduler_e
== KERNEL
) {
71 if ((rv
= sys_schedctl(SCHEDCTL_FLAG_KERNEL
,
72 schedulee_e
, maxprio
, quantum
, cpu
)) != OK
) {
75 *newscheduler_e
= scheduler_e
;
79 /* A user-space scheduler must schedule this process. */
80 memset(&m
, 0, sizeof(m
));
81 m
.m_lsys_sched_scheduling_start
.endpoint
= schedulee_e
;
82 m
.m_lsys_sched_scheduling_start
.parent
= parent_e
;
83 m
.m_lsys_sched_scheduling_start
.maxprio
= maxprio
;
84 m
.m_lsys_sched_scheduling_start
.quantum
= quantum
;
86 /* Send the request to the scheduler */
87 if ((rv
= _taskcall(scheduler_e
, SCHEDULING_START
, &m
))) {
91 /* Store the process' scheduler. Note that this might not be the
92 * scheduler we sent the SCHEDULING_START message to. That scheduler
93 * might have forwarded the scheduling message on to another scheduler
94 * before returning the message.
96 *newscheduler_e
= m
.m_sched_lsys_scheduling_start
.scheduler
;