Unformatted text preview:

System Call Documentation The Tempo vm Operating System Part 5 System Calls Overview System calls for Tempo are documented in the file doc tempo32 txt but beware it is continually under modification For each call the file contains a prototype declaration indicating each of the parameters a textual description of the effect of the system call and indication of the values that might be returned indicating success or failure 1 2 Return Values System Call Categories System calls return System calls can be grouped into several categories NOERROR 0 indicating that the call was successfully completed A negative value indicating an exceptional condition e g 1001 to indicate that an operation was attempted on a non existent message queue A positive value conveying a result e g read and write return the number of bytes processed Error codes are symbolically defined in the file h syserrs h Process functions e g newproca kill Time functions e g sleep and time Memory management functions in infancy Semaphore functions e g up and down Interprocess communication functions e g send receive Low level I O functions console keyboard disk Filesystem and higher level I O functions open read Information functions getsysparm 3 4 Additional Categories Process Management Other operating systems may provide system calls in additional categories Most notable among these are Most modern systems have facilities for process management many also support threads kernel and or user threads Examples Network and protocol related functions Graphic and window related functions including font management Event management e g in Windows Asynchronous signals as in UNIX 5 Windows CreateProcess CreateThread WaitForSingleObject UNIX Linux fork pthread create clone wait waitpid Although these calls vary from system to system the concept of a process is consistently present 6 1 Process Scheduling Process Creation Process scheduling is a rich topic and there are numerous variations The most popular scheduling techniques include Currently the primary system call used in Tempo to create processes is newproca The function newproc is a shorthand version that calls newproca with some default parameters priority based scheduling higher priority tasks run before lower priority tasks run to completion scheduling a process runs until it blocks terminates or voluntarily yields the processor round robin scheduling each process runs for at most a quantum of time before being forced to yield to another ready process at the same priority pid t newproc int root void int prio unsigned stksize root is the name of the function with which execution will begin prio is the initial priority for the new process stksize is the number of pages for the stack 0 means 1 7 8 Tempo newproca Tempo getpid exit getpstate pid t newproca int root int char int prio pid t getpid unsigned stksize unsigned nargs unsigned char args Returns the process ID of the calling process root prio stksize as for newproc void exit int status nargs is the number of command line arguments for the new process Terminates the calling process and provides that status be returned to any processes waiting for this process to terminate args points to an array of nargs null terminated character strings each of which contains one command line argument int getpstate pid t proc Returns the current status of the process with pid proc The status of the calling process is 2 meaning it s running other values defined in file h sysparm h 9 Tempo kill waitpid 10 Tempo quit getprio setprio int kill pid t proc void quit char msg Terminates process proc and returns any resources it owns A process may terminate itself Note that this is not the same as the UNIX kill system call Shuts down the system and display the string pointed to by msg if it is not NULL This should not normally be used by user processes int waitpid pid t proc int exitstatus int timeout int getprio void Waits for process with pid proc to terminate Returns the priority of the currently running process Then returns that process exit status to exitstatus int setprio int newprio timeout indicates how long waitpid should wait INFINITE 1 means wait forever Sets the priority of the currently running process 0 means never wait inappropriate with waitpid 0 means a wait for that many clock ticks 11 12 2 Tempo yield setquantum Tempo getquantum unsigned int getquantum void int yield void Yields the CPU to the process at the head of the ready queue with the same priority as the current process Returns the current quantum size setting for the system int setquantum unsigned int nquantum Sets the quantum size in clock ticks to nquantum If this is 0 the system uses run to completion scheduling Otherwise each process is allowed to run for at most nquantum clock ticks before being preempted by another ready process at the same priority 13 14 Time Functions Windows Examples Many systems have calls that deal with time in one way or another The fundamental calls deal with several types of time GetTickCount void the current wall clock time CPU time used by a process either in user mode or in kernel mode returns the number of milliseconds that have elapsed since the system was started GetSystemTime returns the current system date and time GetSystemTimes returns total processor idle time time spent executing kernel code and time spent executing user mode code Sleep n causes a process to sleep for at least n milliseconds 15 UNIX Linux Example 16 Tempo time sleep unsigned int time void time returns time of day as seconds past 1 1 1970 at midnight UTC times Returns number of clock ticks since the system was started int sleep unsigned int nticks returns kernel and user mode time for the current process and all terminated waited for child processes Causes the current process to sleep block for at least nticks clock ticks nanosleep causes a process to sleep for at least a give time specified in seconds and nanoseconds 17 18 3 Tempo setxlimit getxlimit Question int setxlimit unsigned int nticks Primarily for debugging purposes set the maximum execution time for the entire system to nticks clock ticks If this is 0 as it is by default no limit is enforced How could you provide a system call in Tempo like GetSystemTimes in Windows or the times system call in UNIX unsigned int getxlimit void Return the maximum execution time for the entire system in units of clock ticks This value is 0 if no limit is being enforced It would be necessary to allow clock interrupts


View Full Document

UNO CSCI 8530 - System Calls Overview

Loading Unlocking...
Login

Join to view System Calls Overview and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view System Calls Overview and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?