Press ESC to close

System Calls in OS | Monolithic and Layered Systems

Operating System

Operating systems act as a bridge between hardware and software, managing resources and offering application services. A crucial part of this interface is theย system call. A system call is a request from an application program to the OS kernel to perform a privileged operation. These operations are typically things the application can not do directly due to security restrictions or hardware limitation. This note explores system calls and how they differ in monolithic and layered OS architectures.


System Calls in the Operating System

Concepts related to operating systems include files, processes, address spaces and input/output devices :

1. Process : An executable program is referred to as a process. Every process has a space for addresses. A table known as the “process table” contains all of the process-related data . The process contains all the information needed to run the programm. A process can inhabit any of the five states throughout its lifetime. The systems are running both foreground and background processes that perform various tasks. Interprocess communication is how these processes talk to one another.

2. Address space : The operating system uses a hierarchy to organise files. The information enters the directory.

3. Shell : The UNIX command interpreter is called Shell. Itโ€™s the middleman between the user and the operating system. When you type a command in the terminal, the shell takes it, runs it and then shows the result on the screen.


System Calls Mechanism

When a program wants to read a file while running in user mode, it cannot directly access the hardware. Instead, it asks the operating system for help using a system call.

How it works step by step :

  • The program gives the OS some details (like which file to read, where to store the data and how many bytes to read).
  • These details are placed in a stack (for example: read(fd, buffer, bytes)).
  • A library function is called to make the request.
  • This function usually places the system call number in a register (a special storage place) so the OS knows what action is needed.
  • A TRAP instruction is used to switch control from user mode to kernel mode.
  • The OS looks at the system call number, finds the correct function and runs it.
  • Finally, the requested action (like reading the file) is completed and the result is sent back to the user program.
system calls

System Calls for Process Management

  • Fork : Used to create a new process.
    • The original one is called the parent process.
    • The new one is called the child process.
    • Both look the same at the start.
  • PID (Process ID) : Every process has a unique number (PID).
    • Parent gets the child PID.
    • Child gets 0.
    • This helps the system know which is parent and which is child.
  • Exec : Loads a new program into memory and starts it.
  • Exit : Ends a process.

System Calls for File Management

System calls help us work with files in an operating system. Here are the main ones :

  • open : Used to open a file.
    • We also tell the OS whether we want to read, write or both.
    • The file name is given as a parameter.
  • close : Used to close an opened file.
  • read : Reads data from a file into memory (buffer).
  • write : Writes data from memory (buffer) into a file.
  • lseek : Moves the file pointer to a specific location, so reading/writing can continue from that point.

Every file has a pointer that shows where the next read or write will happen.
Example: When reading a file continuously, the pointer moves forward one byte at a time.


Monolithic System

Monolithic OS has all its functionalities (like file system, memory management, process scheduling) in a single large kernel.

  • The operating system comprises several procedures connected to form a single, sizable executable software.
  • Every process within the system has the liberty to invoke any other process.
  • Having the ability to invoke any operation renders the system highly effective.
  • There is no concealing of information; each procedure is aware of every other procedure.
  • For example, Linux and MS-DOS.
  • This group recommends the following fundamental configuration for the operating system:
  • Primary Purpose: initiates the specified service procedure
  • Service Procedures: execute system commands
  • Utility functions: Assist service procedures in carrying out specific duties
Monolithic system

Advantages of Monolithic System

  • The monolithic approach is a standard way of building applications. No additional knowledge is required.
  • All source code is located in one place which can be quickly understood. Simplicity of debugging. The debugging process is simple because all code is located in one place.
  • You can easily follow the flow of a request and find an issue. Simplicity of testing. You test only one service without any dependencies. Everything is usually clear.

Disadvantages of Monolithic System

  • Complicated and challenging structure.
  • The operating system will crash if any of these processes crash.

Layered System

In operating systems, an architectural design approach known as a “layered system” refers to a setup in which the system is divided into several abstracted layers, each handling a certain functional component. Higher layers are layered on top of lower layers in a hierarchical arrangement. A layered system’s main role is abstraction and modularity.

Below is the layered system mechanism:

Layered system
  • The hardware: This layer is the last layer that communicates directly with the machines, peripherals, CPU, memory, and disk drives. It used the hardware resource control functions, like device drivers.
  • Layer of the Kernel: The kernel is the core central part of the operating system. The kernel has a major role in managing the CPU and memory time.
  • System Call Layer: This layer a establishes a communicator between the user and the system. system calls provide stability and a virtualized environment.
  • User Interface Layer: This layer is used by users. User interface layer you can use the command line tools (CLI) and interact with your operating system. It is also called an application layer. In this layer we can display the data changes in our systems and we also transfer the data from one to another system in just clicking some buttons.

Frequently Asked Questions (FAQs)

  1. What are system calls in an operating system?

    It is used for the interface between user and the operating system(os).

  2. What is a monolithic operating system?

    A monolithic OS has all its functionalities (like file system, memory management, process scheduling) in a single large kernel.

  3. What is a layered operating system?

    A process of different programs that operates the many operations in the layeredย type of system architecture which have different operations and services of the operating system and are split into various layers is called the layered operating system.

  4. Are modern operating systems purely monolithic or layered?

    Most modern OSes are neither purely monolithic nor purely layered. They often use a hybrid approach, combining aspects of both architectures to leverage the strengths of each. They might have a monolithic kernel with modular components.


Related Posts

Read more>>>>

Er. Vaibhav Sharma

Vaibhav Sharma, with a background in Computer Science Engineering, has a passion for writing and simplifying complex technology. At Engineeringa2z, he combines his technical knowledge with clear and engaging content to help readers easily understand and stay informed about the latest in technology.

Leave a Reply

Your email address will not be published. Required fields are marked *