Basic Operating System Services: A beginner’s guide


Gaming Laptop Series

Operating System Services are the basic functionalities or the responsibilities of an Operating System that it provides to the Application programmers and Device Driver Developers to build applications and Device Drivers for a particular Operating System Like: Linux, FreeBSD, Windows or any other OS. In this article I will not go into the Device Driver level deep but I will be explaining Operating System Services concept from application programmer’s perspective and give some examples accordingly to help you understand.

In the last post of What is an Operating System, I gave an example of VLC media player and Windows Media Player (On Windows OS) playing different sound tracks at the same time and how the operating system manages to play both the sound tracks at the same on a single audio hardware.

Here is I have to show you some image presentation of the scenario and explain according to the image:

hardware resource management in operating system

In the image I have drawn the black arrow marks are for the VLC player and the Green arrows are for the Windows media player. Both of the applications are running at the same time and the audio hardware is playing both the sound tracks from both the media players.
VLC media player reads the abc.mp3 from the hard disk, decodes the MP3 file and send the decoded data to the audio hardware to play the sound track.
Windows media player is also reading the xyz.mp3 file from hard disk, decodes the MP3 file and send the digital data to the audio hardware to play the sound track.

So, what’s the role of Operating system in this scenario?

  1. First of all both the media players are running at the same time. Running multiple applications is one of the responsibilities of the OS.
  2. Both the applications are reading some files (this is an input data) from the hard disk. The Operating System has some services to allow the applications to access the Files residing in the hard disk. We will see the Operating System Services shortly.
  3. Both the Applications are sending the decoded content to the audio hardware (this is an output data).
  4. Following are also some responsibilities of the Operating system those are not represented in the image:

  5. It is not represented in the picture but both the media players have to store the data in some of their local memory that they have read from the hard disk. This memory that the applications are using is provided by the Operating System.
  6. It is also not represented by the image, but sometimes applications have to communicate to each other to get some work done, which is also a responsibility of the Operating System.
      For example:

    • – When you run a command from a console (a command line shell). Output of the command is fed back to the console and then the console prints out the data fed by the application.
    • – Another example is when you load some file to your browser. You are required to upload some files from your local systems to some of the websites, let’s say a mail client where you send some files as attachments or a job portal where you need to upload your Resume. In this case the you have to click on Attach button or a Browse button which will open a file Browser which is entirely another application. With the help of the File Browser application you select the file and then click OK. When you click on OK button on the File Browser, the file path is sent back to the Web Browser application.
  7. Sometimes your system has to talk to some other computers in your room connected via LAN (Local Area Networking) or through the internet. The Operating System provides some services to do this.

Here goes the basic Operating System Services based on the above input:

Application or Process execution as a part of Operating System Services:

It is the responsibility of the Operating System to provide some services or functionalities to load and execute an application/Process at the run-time. When there are multiple applications present in the system, then it is the responsibility of the Operating System to execute both of them fairly. This is usually handled by the Scheduler or the Scheduling Algorithm present in the OS. Switching between multiple applications involves context saving and context switching which is also the responsibility of the Scheduler.

Filesystem to manage data as files as a part of Operating System Services:

In the above example VLC media player was reading abc.mp3 and Windows Media Player was reading xyz.mp3 from the hard disk. How they are distinguished differently? Here comes the Filesystem part of the Operating System. The Filesystem present in Operating System helps managing the hard disk contents in files and directories. Directories (called as Folders in Windows) are just place holders which hold files in them and can also contain another directories.

Filesystem is a hierarchical layout which the below image just represents the same:

file and directory layout

Communicate to the external components (Input/Output hardware) of the system as a part of Operating System Services:

A system is more useful when it is flexible in terms of communicating to the external world. Think of an ATM machine without human interaction or without internet connection is really useless. Similarly if an Operating System is unable to handle external devices connected to it will also be useless. So, to deal with this the Operating System has an Input/Output subsystem that manages input and output devices. In our example the Operating System provides a mechanism to the Applications (VLC and Windows media player in our example) to communicate with the Audio Hardware.

You can add/remove a printer to your system, add/remove a USB flash drive or any other USB enabled device to/from your system, which is magically handled by the Operating System Input/Output subsystem.

Memory management as a part of Operating System Services:

An Operating System and its components all run from the System Memory which is the RAM (Random Access Memory). Also, when applications like VLC is loaded or run or executed, some memory has to be allocated to hold the application in memory. On top of that when VLC read some content from the hard disk it should have some place holder to keep the data holding, isn’t it? All the memory in a system has to be maintained by the Operating System for a reliable operation.

Inter Process Communication (IPC) mechanism as a part of Operating System Services:

For IPC mechanism I have already given the example in the upper section. There are times when different processes have to communicate to each other which is not possible if the environment on which they are running (the OS) will not allow to do so. So, the Operating System has to provide some IPC mechanism so that the applications can communicate to each other.

Sometimes multiple applications access a single region of data or resource(anything that can be used by an application code, whether it be some memory region, or some hardware or some structure of data etc. treated as a resource). So, to keep the multiple accesses atomic (exclusive or synchronous) the OS also has some synchronization mechanisms like: Semaphore, Spin Lock and Mutex.

Networking Services as a part of Operating System Services:

An individual PC is not a part of any network. But now a days Wi-Fi is the most portable mode to connect devices to a network. A network without communication is not at all a network but just individual systems.
So, how does a system communicates to other systems in an network? An Operating System in a computer system has Networking Services that enables a system to communicate to other systems.

Secured Access as a part of Operating System Services:

Basically an Operating System is managing the underlying hardware access by various applications. NO application is allowed to access any other application’s data directly. Even NO application is allowed to access a hardware directly. All accesses must go through the Operating System which internally checks access rights.
For example if some application A wants to access other application’s memory lets say B’s memory region then A has to request the OS via Shared Memory IPC mechanism that it wants to access B’s memory region. If process A accesses process B’s memory region directly then process A will be terminated abruptly.

Although there are other things that the Operating System provides like: Debugging Mechanisms, Error detection and handling services etc which are not the basic things but must be included in a system because no software system in this world is bug free.

That’s all folks. I think I have covered Operating System Services with decent examples to help you understand. If you still have any doubt then please do comment here. Also if I have missed something then please do comment to make this article better.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.