OPERATING-SYSTEM OPERATIONS o Interrupt driven by hardware 0 Software error or request creates exception or trap Division by zero,request for operating system service o Other process problems include infinite loop,processes modifying each other or the operating system Dual-mode operation allows Os to protect itself and other system components User mode and kernel mode Mode bit provided by hardware o Provides ability to distinguish when system is running user code or kernel code o Some instructions designated as privileged,only executable in kernel mode o System call changes mode to kernel,return from call resets it to user
OPERATING-SYSTEM OPERATIONS Interrupt driven by hardware Software error or request creates exception or trap Division by zero, request for operating system service Other process problems include infinite loop, processes modifying each other or the operating system Dual-mode operation allows OS to protect itself and other system components User mode and kernel mode Mode bit provided by hardware Provides ability to distinguish when system is running user code or kernel code Some instructions designated as privileged, only executable in kernel mode System call changes mode to kernel, return from call resets it to user
SYSTEM CALLS o Programming interface to the services provided by the os o Typically written in a high-level language (C or C++) o Mostly accessed by programs via a high-level Application Program Interface (API)rather than direct system call use o Three most common APIs are Win32 API for Windows, POSIX API for POSIX-based systems (including virtually all versions of UNIX,Linux,and Mac OS X), and Java API for the Java virtual machine (JVM) o Why use APIs rather than system calls? (Note that the system-call names used throughout this text are generic)
SYSTEM CALLS Programming interface to the services provided by the OS Typically written in a high-level language (C or C++) Mostly accessed by programs via a high-level Application Program Interface (API) rather than direct system call use Three most common APIs are Win32 API for Windows, POSIX API for POSIX-based systems (including virtually all versions of UNIX, Linux, and Mac OS X), and Java API for the Java virtual machine (JVM) Why use APIs rather than system calls? (Note that the system-call names used throughout this text are generic)
SYSTEM CALL IMPLEMENTATION o Typically,a number associated with each system call System-call interface maintains a table indexed according to these numbers o The system call interface invokes intended system call in OS kernel and returns status of the system call and any return values o The caller need know nothing about how the system call is implemented Just needs to obey aPI and understand what OS will do as a result call 0 Most details of OS interface hidden from programmer by API o Managed by run-time support library(set of functions built into libraries included with compiler)
SYSTEM CALL IMPLEMENTATION Typically, a number associated with each system call System-call interface maintains a table indexed according to these numbers The system call interface invokes intended system call in OS kernel and returns status of the system call and any return values The caller need know nothing about how the system call is implemented Just needs to obey API and understand what OS will do as a result call Most details of OS interface hidden from programmer by API Managed by run-time support library (set of functions built into libraries included with compiler)
API SYSTEM CALL-OS RELATIONSHIP user application open() user mode system call interface kernel mode open ( Implementation i of open ( system call : return
API – SYSTEM CALL – OS RELATIONSHIP
STANDARD C LIBRARY EXAMPLE o C program invoking printfO library call,which calls write0 system call #include <stdio.h> int main() -printf("Greetings"); return 0; user mode standard C library kernel mode write ( write() system call
STANDARD C LIBRARY EXAMPLE C program invoking printf() library call, which calls write() system call