System Calls Types, API, OS Relationship

System calls sequence to copy the contents of one file to another file

  • 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?

Example of System Calls

system-calls

Example of Standard API

  • Consider the ReadFile() function in the
  •  Win32 API – a function for reading from a file

Example-of-Standard-API

A description of the parameters passed to ReadFile()
– HANDLE file – the file to be read
– LPVOID buffer – a buffer where the data will be read into and written from
– DWORD bytes To Read – the number of bytes to be read into the buffer
– LPDWORD bytes Read – the number of bytes read during the last read
– LPOVERLAPPED ovl – indicates if overlapped I/O is being used

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)

Standard C Library Example

C program invoking printf() library call, which calls write() system call

example

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

Types of System Calls

  1. Process control
  2. File management
  3. Device management
  4. Information maintenance
  5. Communications
Read More Topics
C++ String
Overloading Binary Operators
Delivery and Forwarding of IP Packets
Overloading Unary Operators
Three Level Addressing – Subnetting

About the author

Santhakumar Raja

Hi, This blog is dedicated to students to stay update in the education industry. Motivates students to become better readers and writers.

View all posts

Leave a Reply