140 likes | 290 Views
1.3 System Call. System Call . System calls provide the interface between a running program and the operating system. System call is a method by which a program make a request to the OS Generally system calls available as assembly-language instructions
E N D
System Call • System calls provide the interface between a running program and the operating system. • System call is a method by which a program make a request to the OS • Generally system calls available as assembly-language instructions • System call will use by executing a software interrupt instruction.
Cont.. • Languages defined to replace assembly language for systems programming allow system calls to be made directly (e.g., C, C++). • Three general methods are used to pass parameters between a running program and the operating system: • Pass parameters in registers. • Store the parameters in a table in memory, and the table address is passed as a parameter in a register. • Push (store) the parameters onto the stack by the program, and pop off the stack by operating system.
System Call Working under Process Management • Calls involve in Process Management • FORK : is used to create a new process. • WAITPID : is used to terminate the process. • PTRACE : is used for debugging • SETSID : create a new session and return its process group id. • BRK : is used to set the size of data segment • System call related to process creation termination
System Call Working under Signaling • Although most interprocess communication are planned, situations exist in which unexpected communication needed.
System Call Working under Signaling • Eg: • when user accidently tell a text editor to list the entire content of long text and then realize the error, some way is needed to interrupt the editor. • User can hit the DEL key on keyboard which send a signal and stop the print – out. Signal also can be used to report certain trap detected by hardware. • When signal is sent to process that has not announced its willingness to accept the signal, the process is simply killed.
System Call Working under Signaling • The calls in Signaling: • SIGACTION: define action to take on signal • SIGRETURN: return from signal • SIGPENDING: get the set of blocked signal • SIGSUSPEND : replace the signal mask and suspend the process • The purpose of SC in signaling is handle the signal
System Call Working under File Management • System call operate on individual files. • Calls in File Management • CREAT : to create a new file fd= creat(“abc”,0751) ; create a file call abc with mode 0751 octal ..specify the rwx for the owner • In C , a leading by zero means that a constant is in octal • Owner :7 means read- write- execute permission) • Group :5 means read-execute • Others :1 means execute only
System Call Working under File Management • OPEN: Open a file for reading, writing or both • CLOSE : Close an open file • WRITE : Write data from a buffer into a class • RENAME: Give a file a new name • The purpose of SC in File Management is reading and writing file
System Call Working under Directory Management • Example of calls involve in this section are • MKDIR : create empty directories • RMDIR : delete directories • LINK : allow the same file to appear under two or more names, often in different directory. (Eg: Allow several members of the same programming team to share common file, which each of them having the file appear in his own directory) • UNLINK : remove the directory entry • The purpose is to manage the directory
System Call Working under Protection • In MINIX every file has an 11-bit used for protection. • These bit are read-write-execute bit for owner, group and others. • CHMOD system call is used to change the mode of a file • To a file read-only by everyone except the owner, could execute : chmod(“filename”, 0644)
System Call Working under Protection • The other two protection bits: • 02000 : SETUID : set-user-id • When any user execute a program with the SETUID bit on, for duration of that process the user’s effective uid is change to that file’s owner. • 04000 : SETGID : set –group-id • When a programs execute, the gid is change to the current gid. • The purpose of system call in protection is to protect information
System Call Working under Time Management • Example, MINIX has 4 system call that involve the time-of-day clock • :Get elapsed time (return the current time in sec :only display the starting time eg: Feb. 2, 2010) • :Set elapsed time (to allow it to be read later: ) • :Set a file’s “last access time ”.(to allow owner of the file to change the time stored) • :Get the user and system times used so far (to know total user and system time used) • The purpose of time Management is keeping track of time
Summary • The heart of any operating system is the set of system call that it can handle • Example for MINIX, these call can be divided into sixth group. Which are • System call related to process creation termination • Handle signal • Reading and writing files • Directory management • Protect information • Keeping track of time