🎧 New: AI-Generated Podcasts Turn your study notes into engaging audio conversations. Learn more

4-System calls, System_Application Call Interface-22-07-2024.pdf

Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...

Full Transcript

Module 2 Operating System Principles System Calls  Provide an interface to the services made available by an operating system.  These calls are generally available as functions written in C and C++.  It is a way for a user program to interface with the operating system.  The program requ...

Module 2 Operating System Principles System Calls  Provide an interface to the services made available by an operating system.  These calls are generally available as functions written in C and C++.  It is a way for a user program to interface with the operating system.  The program requests several services, and the OS responds by invoking a series of system calls to satisfy the request.  A system call is a method for a computer program to request a service from the kernel of the operating system on which it is running.  It acts as a link between the operating system and a process, allowing user-level programs to request operating system services.  When a computer software needs to access the operating system’s kernel, it makes a system call. The system call uses an API to expose the operating system’s services to user programs. It is the only method to access the kernel system. 2 System Calls - Example 3 System Calls – Application Programming Interface  Application developers design programs according to an application programming interface (API).  The API specifies a set of functions that are available to an application programmer, including the parameters that are passed to each function and the return values the programmer can expect.  An API defines the correct way for a developer to request services from an operating system (OS) or other application and expose data within different contexts and across multiple channels.  System calls offer the services of the operating system to the user programs via API (Application Programming Interface). 4 System Calls – Application Programming Interface 5 System Calls – Application Programming Interface  Benefits of API:  An application programmer designing a program using an API can expect his/her program to compile and run on any system that supports the same API.  Actual system calls can often be more detailed and difficult to work with than the API available to an application programmer. 6 API – System Call – OS Relationship  The handling of a user application invoking the open() system call. Figure: The handling of a user application invoking the open() system call 7 System Call Implementation  Run-time environment (RTE) is the full suite of software needed to execute applications written in a given programming language.  It provides a system-call interface that serves as the link to system calls.  A number is associated with each system call, and the system-call interface maintains a table indexed according to these numbers.  The system-call interface then invokes the intended system call in the operating-system kernel and returns the status of the system call.  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) 8 System Call Parameter Passing  Often, more information is required than simply identity of desired system call Exact type and amount of information vary according to OS and call  Three general methods used to pass parameters to the OS  Simplest: pass the parameters in registers In some cases, may be more parameters than registers  Parameters stored in a block, or table, in memory, and address of block passed as a parameter in a register. This approach taken by Linux and Solaris  Parameters placed, or pushed, onto the stack by the program and popped off the stack by the operating system Block and stack methods do not limit the number or length of parameters being passed The second and third approaches do not limit the number or length of parameters being passed. 9 Parameter Passing via Table/Block 10 System Calls – working steps  A user program wants to read data from a file:  The user program starts executing in the user mode.  The program issues a read system call to request the operating system to read data from the file.  The processor identifies the read system call and invokes it.  The control of the process goes to the kernel mode.  The operating system performs the necessary actions to read data from the file.  Once the read system call’s execution gets complete, the control of the process returns to the user mode.  The user program continues executing with the data that was read from the file. 11 System Calls – Types System calls can be grouped roughly into six major categories: Process control  create process, terminate process  end, abort  load, execute  get process attributes, set process attributes  wait for time  wait event, signal event  allocate and free memory  Dump memory if error  Debugger for determining bugs, single step execution  Locks for managing access to shared data between processes 12 System Calls – Types  File management  create file, delete file  open, close file  read, write, reposition  get and set file attributes  Device management  Request device, release device  Read, write, reposition  Get device attributes, set device attributes  Logically attach or detach devices 13 System Calls – Types  Information maintenance  get time or date, set time or date  get system data, set system data  get and set process, file, or device attributes  Communications  create, delete communication connection  send, receive messages if message passing model to host name or process name  From client to server  Shared-memory model create and gain access to memory regions  transfer status information  attach and detach remote devices 14 System Calls – Types  Protection Control access to resources Get and set permissions Allow and deny user access 15 System Calls – Example 16

Use Quizgecko on...
Browser
Browser