What is System Call?



System call is a way through which CPU can access the kernel mode from user mode. There are different types of system calls to perform different tasks. When System Call is generated then CPU switch form user mode to kernel mode and performs that particular task and turns back to user mode again. That’t why, these two modes also called CPU execution modes.

There are some systems calls like

  • PRINTF in C language
  • CreateFile(),ReadFile(), WriteFile() and CloseHandle() in file management

As we know, Processes run in user mode by CPU until the system call occur. When it occur then control of CPU shift to kernel mode.

Let’s Explain with example, When we are using the translator of C language and put a command like “PRINTF” then this command will first check in Standard Library of that program. If that particular command exist in Standard Library then that command moves to System Call Handler in Kernel Mode. Otherwise invalid system call message will appear without going to Kernel mode. Explanation is given under with diagram

Importance

If applications go to directly read and write to the kernel space then system stability and security will be gone. Because there will be no restriction for any user to access protected area. So, Kernel mode is the basic need.

Purpose

System calls are mostly used when a process in user mode requires access to a resource.

Situations 

There are some basic situations when system calls is invoked,


  • Creation of new processes.
  • Reading and writing, creation or deletion the file
  • Network connections, sending and receiving packets.
  • Accessing the devices such as a printer, scanner etc.

A table of system calls in Windows and Linux OS is given below.

Types of System Calls

Windows

Linux

Process Control
CreateProcess()
ExitProcess()
WaitForSingleObject()
fork()
exit()
wait()
File Management
CreateFile()
ReadFile()
WriteFile()
CloseHandle()
open()
read()
write()
close()
Device Management
SetConsoleMode()
ReadConsole()
WriteConsole()
ioctl()
read()
write()
Information Maintenance
GetCurrentProcessID()
SetTimer()
Sleep()
getpid()
alarm()
sleep()
Communication
CreatePipe()
CreateFileMapping()
MapViewOfFile()
pipe()
shmget()
mmap()

 

Help Other’s By Sharing…

Contact Us

Burewala, Vehari, Punjab, Pakistan

cstaleem1@gmail.com

Website: CStaleem.com

Pin It on Pinterest