1 /* The kernel call implemented in this file:
4 * The parameters for this kernel call are:
5 * m1_i1: PR_ENDPT (endpoint of process to clean up)
8 #include "kernel/system.h"
10 #include <minix/endpoint.h>
14 /*===========================================================================*
16 *===========================================================================*/
17 int do_clear(struct proc
* caller
, message
* m_ptr
)
19 /* Handle sys_clear. Only the PM can request other process slots to be cleared
20 * when a process has exited.
21 * The routine to clean up a process table slot cancels outstanding timers,
22 * possibly removes the process from the message queues, and resets certain
23 * process table fields to the default values.
29 if(!isokendpt(m_ptr
->PR_ENDPT
, &exit_p
)) { /* get exiting process */
32 rc
= proc_addr(exit_p
); /* clean up */
34 release_address_space(rc
);
36 /* Don't clear if already cleared. */
37 if(isemptyp(rc
)) return OK
;
39 /* Check the table with IRQ hooks to see if hooks should be released. */
40 for (i
=0; i
< NR_IRQ_HOOKS
; i
++) {
41 if (rc
->p_endpoint
== irq_hooks
[i
].proc_nr_e
) {
42 rm_irq_handler(&irq_hooks
[i
]); /* remove interrupt handler */
43 irq_hooks
[i
].proc_nr_e
= NONE
; /* mark hook as free */
47 /* Remove the process' ability to send and receive messages */
50 /* Turn off any alarm timers at the clock. */
51 reset_timer(&priv(rc
)->s_alarm_timer
);
53 /* Make sure that the exiting process is no longer scheduled,
54 * and mark slot as FREE. Also mark saved fpu contents as not significant.
56 RTS_SETFLAGS(rc
, RTS_SLOT_FREE
);
60 rc
->p_misc_flags
&= ~MF_FPU_INITIALIZED
;
62 /* Release the process table slot. If this is a system process, also
63 * release its privilege structure. Further cleanup is not needed at
64 * this point. All important fields are reinitialized when the
65 * slots are assigned to another, new process.
67 if (priv(rc
)->s_flags
& SYS_PROC
) priv(rc
)->s_proc_nr
= NONE
;
70 /* Clean up virtual memory */
71 if (rc
->p_misc_flags
& MF_VM
) {
79 #endif /* USE_CLEAR */