minix/minix/kernel/ipc.h

51 lines
2 KiB
C
Raw Normal View History

#ifndef IPC_H
#define IPC_H
/* This header file defines constants for MINIX inter-process communication.
* These definitions are used in the file proc.c.
*/
#include <minix/com.h>
#include <minix/ipcconst.h>
/* Masks and flags for system calls. */
2007-04-23 15:44:56 +02:00
#define NON_BLOCKING 0x0080 /* do not block if target not ready */
Userspace scheduling - cotributed by Bjorn Swift - In this first phase, scheduling is moved from the kernel to the PM server. The next steps are to a) moving scheduling to its own server and b) include useful information in the "out of quantum" message, so that the scheduler can make use of this information. - The kernel process table now keeps record of who is responsible for scheduling each process (p_scheduler). When this pointer is NULL, the process will be scheduled by the kernel. If such a process runs out of quantum, the kernel will simply renew its quantum an requeue it. - When PM loads, it will take over scheduling of all running processes, except system processes, using sys_schedctl(). Essentially, this only results in taking over init. As children inherit a scheduler from their parent, user space programs forked by init will inherit PM (for now) as their scheduler. - Once a process has been assigned a scheduler, and runs out of quantum, its RTS_NO_QUANTUM flag will be set and the process dequeued. The kernel will send a message to the scheduler, on the process' behalf, informing the scheduler that it has run out of quantum. The scheduler can take what ever action it pleases, based on its policy, and then reschedule the process using the sys_schedule() system call. - Balance queues does not work as before. While the old in-kernel function used to renew the quantum of processes in the highest priority run queue, the user-space implementation only acts on processes that have been bumped down to a lower priority queue. This approach reacts slower to changes than the old one, but saves us sending a sys_schedule message for each process every time we balance the queues. Currently, when processes are moved up a priority queue, their quantum is also renewed, but this can be fiddled with. - do_nice has been removed from kernel. PM answers to get- and setpriority calls, updates it's own nice variable as well as the max_run_queue. This will be refactored once scheduling is moved to a separate server. We will probably have PM update it's local nice value and then send a message to whoever is scheduling the process. - changes to fix an issue in do_fork() where processes could run out of quantum but bypassing the code path that handles it correctly. The future plan is to remove the policy from do_fork() and implement it in userspace too.
2010-03-29 13:07:20 +02:00
#define FROM_KERNEL 0x0100 /* message from kernel on behalf of a process */
#define WILLRECEIVE(src_e,dst_ptr,m_src_v,m_src_p) \
((RTS_ISSET(dst_ptr, RTS_RECEIVING) && \
!RTS_ISSET(dst_ptr, RTS_SENDING)) && \
CANRECEIVE(dst_ptr->p_getfrom_e,src_e,dst_ptr,m_src_v,m_src_p))
#define CANRECEIVE(receive_e,src_e,dst_ptr,m_src_v,m_src_p) \
(((receive_e) == ANY || (receive_e) == (src_e)) && \
(priv(dst_ptr)->s_ipcf == NULL || \
allow_ipc_filtered_msg(dst_ptr,src_e,m_src_v,m_src_p)))
/* IPC status code macros. */
#define IPC_STATUS_GET(p) ((p)->p_reg.IPC_STATUS_REG)
2010-04-26 16:43:59 +02:00
#define IPC_STATUS_CLEAR(p) ((p)->p_reg.IPC_STATUS_REG = 0)
/*
* XXX: the following check is used to set the status code only on RECEIVE.
* SENDREC is not currently atomic for user processes. A process can return
* from SENDREC in a different context than the original when a Posix signal
* handler gets executed. For this reason, it is not safe to manipulate
* the context (i.e. registers) when a process is blocked on a SENDREC.
* Unfortunately, avoiding setting the status code for SENDREC doesn't solve
* the problem entirely because in rare situations it is still necessary to
* override retreg dynamically (and possibly in a different context).
* A possible reliable solution is to improve our Posix signal handling
* implementation and guarantee SENDREC atomicity w.r.t. the process context.
*/
#define IPC_STATUS_ADD(p, m) do { \
if(!((p)->p_misc_flags & MF_REPLY_PEND)) { \
(p)->p_reg.IPC_STATUS_REG |= (m); \
} \
} while(0)
#define IPC_STATUS_ADD_CALL(p, call) \
IPC_STATUS_ADD(p, IPC_STATUS_CALL_TO(call))
#define IPC_STATUS_ADD_FLAGS(p, flags) \
IPC_STATUS_ADD(p, IPC_STATUS_FLAGS(flags))
#endif /* IPC_H */