* Userspace change to use the new kernel calls - _taskcall(SYSTASK...) changed to _kernel_call(...) - int 32 reused for the kernel calls - _do_kernel_call() to make the trap to kernel - kernel_call() to make the actuall kernel call from C using _do_kernel_call() - unlike ipc call the kernel call always succeeds as kernel is always available, however, kernel may return an error * Kernel side implementation of kernel calls - the SYSTEm task does not run, only the proc table entry is preserved - every data_copy(SYSTEM is no data_copy(KERNEL - "locking" is an empty operation now as everything runs in kernel - sys_task() is replaced by kernel_call() which copies the message into kernel, dispatches the call to its handler and finishes by either copying the results back to userspace (if need be) or by suspending the process because of VM - suspended processes are later made runnable once the memory issue is resolved, picked up by the scheduler and only at this time the call is resumed (in fact restarted) which does not need to copy the message from userspace as the message is already saved in the process structure. - no ned for the vmrestart queue, the scheduler will restart the system calls - no special case in do_vmctl(), all requests remove the RTS_VMREQUEST flag
43 lines
1.3 KiB
C
43 lines
1.3 KiB
C
#include "sysutil.h"
|
|
#include <timers.h>
|
|
|
|
/*===========================================================================*
|
|
* tickdelay *
|
|
*===========================================================================*/
|
|
PUBLIC int tickdelay(ticks)
|
|
long ticks; /* number of ticks to wait */
|
|
{
|
|
/* This function uses the synchronous alarm to delay for a while. This works
|
|
* even if a previous synchronous alarm was scheduled, because the remaining
|
|
* tick of the previous alarm are returned so that it can be rescheduled.
|
|
* Note however that a long tick_delay (longer than the remaining time of the
|
|
* previous) alarm will also delay the previous alarm.
|
|
*/
|
|
message m, m_alarm;
|
|
int s;
|
|
|
|
if (ticks <= 0) return OK; /* check for robustness */
|
|
|
|
m.ALRM_EXP_TIME = ticks; /* request message after ticks */
|
|
m.ALRM_ABS_TIME = 0; /* ticks are relative to now */
|
|
s = _kernel_call(SYS_SETALARM, &m);
|
|
if (s != OK) return(s);
|
|
|
|
receive(CLOCK,&m_alarm); /* await synchronous alarm */
|
|
|
|
/* Check if we must reschedule the current alarm. */
|
|
if (m.ALRM_TIME_LEFT > 0 && m.ALRM_TIME_LEFT != TMR_NEVER) {
|
|
m.ALRM_EXP_TIME = m.ALRM_TIME_LEFT - ticks;
|
|
if (m.ALRM_EXP_TIME <= 0)
|
|
m.ALRM_EXP_TIME = 1;
|
|
s = _kernel_call(SYS_SETALARM, &m);
|
|
}
|
|
|
|
return(s);
|
|
}
|
|
|
|
|
|
|
|
|
|
|