What are the purpose of system calls explain the user mode and kernel mode of an operating system?

Skip to main content

This browser is no longer supported.

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

User mode and kernel mode

  • Article
  • 12/15/2021
  • 2 minutes to read

In this article

A processor in a computer running Windows has two different modes: user mode and kernel mode.

The processor switches between the two modes depending on what type of code is running on the processor. Applications run in user mode, and core operating system components run in kernel mode. While many drivers run in kernel mode, some drivers may run in user mode.

User mode

When you start a user-mode application, Windows creates a process for the application. The process provides the application with a private virtual address space and a private handle table. Because an application's virtual address space is private, one application cannot alter data that belongs to another application. Each application runs in isolation, and if an application crashes, the crash is limited to that one application. Other applications and the operating system are not affected by the crash.

In addition to being private, the virtual address space of a user-mode application is limited. A processor running in user mode cannot access virtual addresses that are reserved for the operating system. Limiting the virtual address space of a user-mode application prevents the application from altering, and possibly damaging, critical operating system data.

Kernel mode

All code that runs in kernel mode shares a single virtual address space. This means that a kernel-mode driver is not isolated from other drivers and the operating system itself. If a kernel-mode driver accidentally writes to the wrong virtual address, data that belongs to the operating system or another driver could be compromised. If a kernel-mode driver crashes, the entire operating system crashes.

This diagram illustrates communication between user-mode and kernel-mode components.

What are the purpose of system calls explain the user mode and kernel mode of an operating system?

Virtual Address Spaces

Feedback

Submit and view feedback for


The interface between a process and an operating system is provided by system calls. In general, system calls are available as assembly language instructions. They are also included in the manuals used by the assembly level programmers. System calls are usually made when a process in user mode requires access to a resource. Then it requests the kernel to provide the resource via a system calls.

In general, system calls are required in the following situations −

  • If a file system requires the creation or deletion of files. Reading and writing from files also require a system call.
  • Creation and management of new processes.
  • Network connections also require system calls. This includes sending and receiving packets.
  • Access to a hardware device such as a printer, scanner etc. requires a system call.

Types of System Calls

There are mainly five types of system calls. These are explained in detail as follows -

Process Control

These system calls deal with processes such as process creation, process termination etc.

File Management

These system calls are responsible for file manipulation such as creating a file, reading a file, writing into a file etc.

Device Management

These system calls are responsible for device manipulation such as reading from device buffers, writing into device buffers etc.

Information Maintenance

These system calls handle information and its transfer between the operating system and the user program.

Communication

These system calls are useful for interprocess communication. They also deal with creating and deleting a communication connection.

Some of the examples of all the above types of system calls in Windows and Unix are given as follows -

Types of System CallsWindowsLinux
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()

Purpose of System Calls

There are many different system calls as shown above. The purpose of some of those system calls is as follows -

open()

The open() system call is used to provide access to a file in a file system. This system call allocates resources to the file and provides a handle that the process uses to refer to the file. A file can be opened by multiple processes at the same time or be restricted to one process. It all depends on the file organization and file system.

read()

The read() system call is used to access data from a file that is stored in the file system. The file to read can be identified by its file descriptor and it should be opened using open() before it can be read. In general, the read() system calls takes three arguments i.e. the file descriptor, the buffer which stores read data and the number of bytes to be read from the file.

write()

The write() system call writes the data from a user buffer into a device such as a file. This system call is one of the ways to output data from a program. In general, the write() system calls takes three arguments i.e. the file descriptor,the pointer to the buffer where data is stored and the number of bytes to write from the buffer.

close()

The close() system call is used to terminate access to a file system. Using this system call means that the file is no longer required by the program and so the buffers are flushed, the file metadata is updated and the file resources are de-allocated.

wait()

In some systems, a process may wait for another process to complete its execution. This happens when a parent process creates a child process and the execution of the parent process is suspended until the child process executes. The suspending of the parent process occurs with a wait() system call. When the child process completes execution, the control is returned back to the parent process.

This system call runs an executable file in the context of an already running process. It replaces the previous executable file. This is known as an overlay. The original process identifier remains since a new process is not created but data, heap, stack etc. of the process are replaced by the new process.

fork()

Processes use the fork() system call to create processes that are a copy of themselves. This is one of the major methods of process creation in operating systems. When a parent process creates a child process and the execution of the parent process is suspended until the child process executes. When the child process completes execution, the control is returned back to the parent process.

exit()

The exit() system call is used by a program to terminate its execution. In a multithreaded environment, this means that the thread execution is complete. The operating system reclaims resources that were used by the process after the exit() system call.

kill()

The kill() system call is used by the operating system to send a termination signal to a process that urges the process to exit. However, kill() system call does not necessarily mean killing the process and can have various meanings.

What are the purpose of system calls explain the user mode and kernel mode of an operating system?

Updated on 22-Jun-2020 14:25:42

  • Related Questions & Answers
  • What is the purpose of System Programs?
  • What is the purpose of Database Management System?
  • What is the purpose of System class in Java?
  • What are system calls in Operating System?
  • What are the different system calls in the operating system?
  • What are the Process Management System Calls?
  • What is the basic purpose of a Database Management system(DBMS)?
  • Different types of system calls
  • What are the types of system calls used in file management?
  • How are system calls connected to the operating system?
  • What is the purpose of any research?
  • What is the purpose of Human Life?
  • What is the purpose of Risk Management?
  • What is the purpose of the command interpreter?
  • What is the purpose of the testng.xml file?

What is the purpose of system calls in operating system?

System call provides the services of the operating system to the user programs via Application Program Interface(API). It provides an interface between a process and operating system to allow user-level processes to request services of the operating system. System calls are the only entry points into the kernel system.

What is kernel mode and user mode in operating system?

In kernel mode, the program has direct and unrestricted access to system resources. In user mode, the application program executes and starts. Interruptions. In Kernel mode, the whole operating system might go down if an interrupt occurs. In user mode, a single process fails if an interrupt occurs.

What is the purpose of system calls explain two types of it?

In general, system calls are available as assembly language instructions. They are also included in the manuals used by the assembly level programmers. System calls are usually made when a process in user mode requires access to a resource. Then it requests the kernel to provide the resource via a system call.

Why is the user mode and kernel mode both needed in an operating system?

Necessity of Dual Mode (User Mode and Kernel Mode) in Operating System. A running user program can accidentaly wipe out the operating system by overwriting it with user data. Multiple processes can write in the same system at the same time, with disastrous results.