You are on page 1of 1
Lab 4 Friday,5 February 2021 8:32 AM erating System Lab Exp 5. Write aC or JAVA progham to stinlate mitersupt and system call handler. The interface between the OS and the user programs is defined by the set of system callsto get services of OS. Thus, the entire OS is divided into four sets of system calls corresponding to four resource management modules. When a user needs services of OS, he embeds a system call which has the same name as C-library of subroutines with appropriate parametersas its arguments. When CPU executes his program and encounters a system call, a trap instruction is executed and the control goes from user mode to kee! mode. The OS inspects the parameters and finds out what the service is requested, provide service by executing system call code and retum control to OS which decides whether execute the program which has called he system call or execute some other programs. For example considera system call given by ‘count = read ( fd, buffer, nbytes); which reads nbytes from a file fd and put it into the buffer. It returns the actual number of bytes in count. It is either ubytes or the actual number of bytes read ifthe EOF is encountered before read is completed. If the system call can not be carried out, either due to an invalid parameter or a disk error, the count is set to -1 and the 1 cerrornumber is put in a global variable erro. To process this system call, the

You might also like