xref: /minix3/minix/lib/libsys/sched_stop.c (revision 685aa79304a3b43efa0194233b5d70cfb6df335e)
1433d6423SLionel Sambuc #include "syslib.h"
2433d6423SLionel Sambuc #include <assert.h>
3433d6423SLionel Sambuc #include <string.h>
4*685aa793SDavid van Moolenbroek #include <minix/sched.h>
5433d6423SLionel Sambuc 
6433d6423SLionel Sambuc /*===========================================================================*
7433d6423SLionel Sambuc  *				sched_stop				     *
8433d6423SLionel Sambuc  *===========================================================================*/
sched_stop(endpoint_t scheduler_e,endpoint_t schedulee_e)9433d6423SLionel Sambuc int sched_stop(endpoint_t scheduler_e, endpoint_t schedulee_e)
10433d6423SLionel Sambuc {
11433d6423SLionel Sambuc 	int rv;
12433d6423SLionel Sambuc 	message m;
13433d6423SLionel Sambuc 
14433d6423SLionel Sambuc 	/* If the kernel is the scheduler, it will implicitly stop scheduling
15433d6423SLionel Sambuc 	 * once another process takes over or the process terminates */
16433d6423SLionel Sambuc 	if (scheduler_e == KERNEL || scheduler_e == NONE)
17433d6423SLionel Sambuc 		return(OK);
18433d6423SLionel Sambuc 
19433d6423SLionel Sambuc 	/* User-scheduled, perform the call */
20433d6423SLionel Sambuc 	assert(_ENDPOINT_P(scheduler_e) >= 0);
21433d6423SLionel Sambuc 	assert(_ENDPOINT_P(schedulee_e) >= 0);
22433d6423SLionel Sambuc 
23433d6423SLionel Sambuc 	memset(&m, 0, sizeof(m));
24433d6423SLionel Sambuc 	m.m_lsys_sched_scheduling_stop.endpoint	= schedulee_e;
25433d6423SLionel Sambuc 	if ((rv = _taskcall(scheduler_e, SCHEDULING_STOP, &m))) {
26433d6423SLionel Sambuc 		return rv;
27433d6423SLionel Sambuc 	}
28433d6423SLionel Sambuc 
29433d6423SLionel Sambuc 	return (OK);
30433d6423SLionel Sambuc }
31