DOC PREVIEW
UNO CSCI 8530 - System Calls Overview

This preview shows page 1-2-3-27-28-29 out of 29 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 29 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 29 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 29 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 29 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 29 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 29 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 29 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

1The Tempo Operating SystemPart 5System Calls -- OverviewLast edited: 10/1/2007System Call DocumentationSystem calls for Tempo are documented in the file doc/tempo.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).2Documentation for other systems…For UNIX, system calls are described in section two of the manual pages. For example, the command “man 2 fork” describes the fork system call.Microsoft Windows system service descriptions can be found on MSDN (msdn.microsoft.com). Once there, select “Library” (from the top tabs), then “Win32 and COM Development” and “System Services” (from the left panel).Return ValuesTempo’s system calls return:NOERROR (0) indicating that the call was successfully completed, orA negative value indicating an exceptional condition (e.g. –1001 to indicate that an operation was attempted on a non-existent message queue), orA 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”3System Call CategoriesSystem calls may be grouped into several categories:Process functions (e.g. newproca, kill)Time functions (e.g. sleep and time)Memory management functions (e.g. brk)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)Additional CategoriesOther operating systems may provide system calls in additional categories. Most notable among these are:Network and protocol-related functions (e.g. socket)Window-related functions (e.g. CreateWindow)Graphics/multimedia/font management functionsEvent management (e.g. in Windows: GetMessage)Asynchronous signals (as in UNIX: sigaction, kill)4Process ManagementMost modern systems have facilities for process management; many also support threads (kernel and/or user threads). Examples:Windows: CreateProcess, CreateThread, WaitForSingleObjectUNIX/Linux: fork, pthread_create, clone, wait/waitpidAlthough these calls vary from system to system, the concept of a “process” is consistently present.Process SchedulingProcess scheduling is a “rich” topic, and there are numerous variations.The most popular scheduling techniques include:priority-based scheduling: higher priority tasks run before lower priority tasksrun-to-completion scheduling: a process runs until it blocks, terminates, or voluntarily yields the processorround-robin scheduling: each process runs for at most a ‘quantum’ of time before being forced to yield to another ready process at the same priorityObserve that priority-based scheduling can be used with run-to-completion or round-robin scheduling, as in Tempo.5Process CreationCurrently, 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.pid_t newproc (int (*root)(void), int prio, unsigned stksize)root is the name of the function with which execution will beginprio is the initial priority for the new processstksize is the number of pages for the stack (0 means 1)Tempo: newprocaroot, prio, stksize as for newprocnargs is the number of “command line” arguments for the new processargs points to an array of nargs null-terminated character strings, each of which contains one command-line argument.pid_t newproca (int (*root)(int,char **), int prio,unsigned stksize, unsigned nargs, unsigned char **args)Note that this call actually creates an object that should more appropriately be called a “thread” since it shares the same address space as the kernel and other threads. That is, the “process” created by newproca can access the address space of other “processes” created using newproca.6Tempo: getpid, exit, getpstateReturns the process ID of the calling process.pid_t getpid ()Terminates the calling process, and provides that status be returned to any processes waiting for this process to terminate.void exit (int status)Returns the current status of the process with pid proc. The status of the calling process is 2 (meaning it’s running); other valuesdefined in file “h/sysparm.h”int getpstate (pid_t proc)Tempo: kill, waitpidTerminates process proc and returns any resources it owns. A process may terminate itself. Note that this is notthe same as the UNIX killsystem call.int kill (pid_t proc)Waits for process with pid proc to terminate.Then returns that process’ exit status to exitstatus.timeout indicates how long waitpid should wait:INFINITE (-1) means wait forever0 means never wait (inappropriate with waitpid)> 0 means a wait for that many millisecondsint waitpid (pid_t proc, int *exitstatus, int timeout)7Tempo: quit, getprio, setprioShuts 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.void quit (char *msg)Returns the priority of the currently-running process.int getprio (void)Sets the priority of the currently-running process. This could result in a different process obtaining control of the CPU if the new priority is less than that of another ready process.int setprio (int newprio)Tempo: yield, setquantumYields the CPU to any other ready process. Note this could not be a higher priority process, as it would already be running. Likewise, it could not be a lower priority process, as allowing it to run would violate the priority principle (a highest-priority ready process is always running).int yield (void)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 nquantumclock ticks before being preempted by another ready process at the same priority. The call returns the previous quantum setting.int setquantum (unsigned int nquantum)8Tempo: getquantumReturns the current quantum size setting for the system.unsigned int getquantum (void)Time FunctionsMany systems have calls that deal with time in one way or another. The fundamental calls deal with several “types” of time:the current “wall clock” timeCPU time used by a process (either in user mode or in


View Full Document

UNO CSCI 8530 - System Calls Overview

Download System Calls Overview
Our administrator received your request to download this document. We will send you the file to your email shortly.
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 2 2 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?