A computing system consists of following components
Figure 1 Computing System Components
Operating systems are of different types. There are OS which are less than 1 MB or small enough to even fit on a floppy. These OS have the very basic functionalities. On the other hand one has the OS that are of several MB size. These OS have in addition lot of utilities apart from the basic functionalities. Thus the OS mainly consist of a Kernel and utilities. The kernel is the heart of an OS and has the main functionalities of the OS. The utilities that come along with this are to provide the environment for users/processes to use the kernel in a better way.
Operating system services or
functionalities can be divided into the following functionalities:
Process
Management:
To understand what is process management, we need to understand what is a process. In simple terms a process is a running instance of a program. When a program is executed by a computing system, the object file (or the executable file) is loaded in the memory and then CPU starts executing the instructions in the object file one by one. At any given instance of time the CPU keeps track of the memory location from which to execute the next instruction. Thus the process has a state, which constitutes, the memory space it occupies, the next instruction to be executed and the variables it keeps track of. Process is a very complex entity and has much more details, which are beyond the syllabus of this course.
Two important concepts to remember are that A) Processes can be “Kernel processes” which means that the kernel itself has many processes to carry out the various operating system chores. These kernel processes run in a separate space in the memory specifically allocated for the kernel (kernel memory space). B) Modern operating systems are multi-tasking, in that they support multiple processes. That is more than one process can run at the same time.
Thus process management constitutes the following tasks
§ Creation/Deletion of user & kernel processes - when a user wants to execute a program or when the OS wants to execute some OS related task, the kernel loads the executable program in the memory, initializes the process memory space and other data structures and starts the execution of the process. This is creation of a process. Similarly, when the process finishes its task or when the user wants to terminate the process immaturely, the OS stops the process and cleans up the process space and other related data structures.
§ Suspension/Resumption of processes – Many times a process is put to sleep (either purposefully) or it is waiting for some event to occur. In such cases, the OS takes care of suspending the operation of a process and then again resuming the operation when the sleep time expires or when the desired event occurs.
§ Process Switching – Modern OS support multi-tasking by “Time-Slicing”. CPU divides its operation in fixed time slots. When this time expires the OS switches out the process currently being executed and loads a new process to be executed. By keeping this time slot small, many processes can be run quickly in a given time slots, giving an illusion to a user that his process is the one which is being executed continuously and exclusively by the CPU. The process of taking a process out of execution and getting a new one is called process switching (also known as context switching).
§ Process Communication – In practical world many process need to communicate with each other to pass information or signals to each other. One example in Windows OS is when you do “End Task” from a Task Manager to a specific process. Task Manager is a process, which sends “Stop Signal” to the process to be killed or stopped. OS needs to manage these communications between processes.
Main Memory
Management
Main Memory can be thought of a large array of bytes(or words), where each byte(or word) has its own unique address. It is also referred as RAM (Random Access Memory). CPU can access instructions or data directly only from main memory. Thus whenever a process is to be executed it has to be loaded in main memory (Figure 2). Also if any piece of data is to be manipulated, it has to be loaded in main memory from secondary storage (usually hard disk) (figure 3).
Figure 2 CPU - Memory Interaction
Figure 3 The Data/Instruction is first loaded in main memory
Many processes/data is loaded in the memory at any given instance of time. Main Memory management includes the following tasks.
§ Keep track of what part of memory is allocated and what part is available for use.
§ Which process to load when memory becomes available
§ Allocate/deallocate memory space whenever a process is to be created destroyed. Also, whenever a process requests for memory space and later releases it, allocate and deallocate memory space.
File Management
Computing systems consists of several secondary storage devices like Disks, Floppy, Tape, CD etc. Each device has different physical properties like speed, capacity, type(optical, magnetic). One important function of the OS is to abstract all these devices in one uniform logical view. One important aspect of this abstraction is the concept of ‘File’. File is a logical storage unit of information. Usually a file constitutes a sequence if bits and bytes with additional information like name of file, length of file, creation time, user name etc. It doesn’t matter for a user or a user process where the file resides; it could be residing on a magnetic disk/floppy or optical CD. The way a file is opened, closed or manipulated is same irrespective of the physical device on which it is stored. This abstraction of file makes it very easy for a user to deal with secondary storage information. To organize these files properly, modern OS also support the concept of directories where these files can be organized in a group. Also these directories are organized in the form or a file hierarchy or file tree. File management thus constitutes of
§ Creation/deletion of files – Initializing data structures corresponding to files when a file is created (to store additional information about files). Also allocating space on the secondary storage to store the file information. Also, when the file is deleted destroy the data structures and free allocated space for the file information.
§ Creation/deletion of directories – Initializing data structures corresponding to directories when a directory is created (to store additional information about directory). Also allocating space on the secondary storage to store the directory information. Also, when the directory is deleted destroy the data structures and free allocated space for the directory information.
§ Primitives to manipulate files and directories – OS provides many primitives to manipulate files and directories like copying files/directories, moving files/directories, creating links/shortcuts etc
§ Manage secondary storage – Manage space on secondary storage device. Allocate/deallocate space. Keep track of how much space is available etc.
I/O System
Management
An important function of the OS is to abstract the peculiarities of the Hardware devices to the user. Each device is usually managed by its “Device driver” which is shipped along with it. The device driver knows the details of the hardware. Take an example of a Device driver for a hard disk. A hard disk is made up of a magnetic disk(s) with a magnetic head mounted on a spindle moving on top if it. When the OS wants to reas data frpm the disk, t requests the device driver of the hard disk for it. The device driver then takes care of handling the low level details of the hardware, by moving the head to the appropriate location (the motor of the spindle etc). Thus the device driver takes care of the low level details. The I/O subsystem of an OS includes thus,
Networking System
Every modern operating system supports networking, an ability to communicate with distant computing systems. Each OS has support for more than one networking protocol suites. Most important of them is the TCP/IP suite. Let us consider the TCP/IP suite. Figure 4 shows the way the TCP/IP protocol suite is supported by the OS .
Figure 4 Organization of TCP/IP suite in OS
The transport and the network layer protocols are part of the OS kernel itself as they are the accepted standards. The type of NIC card attached to a computer supports each type of physical network. Thus if the computer is to be connected to an Ethernet network, a Ethernet card needs to be attached to the computer. The data link layer is part of the device driver that comes along with the NIC. Thus any type of physical network can be supported provided we have the correct device driver and the correct card. This is in line with the philosophy of IP, where IP can run on any type of physical network. The application programs are written by users which run on any one of the transport layer (UDP or TCP). The OS abstracts these details of the networking protocols in the forms of files or sockets, which makes writing application programs on networking easy.
Protection System
We already discussed that modern OS support multiple users, which mean that many users can access the computer at the same time. In such a scenario, it is important that the OS provides a protection mechanism, which includes the following
§ Protect process/users from each other’s activities. This means that no arbitrary user can interfere or obstruct the working of other user and his processes. This prevents malicious or fraudulent activities
§ The OS achieves this by providing different levels of privileges and authority to each user. This ranges from minimum privileges to full privilege for a super-user (or administrator). Thus before allocating accesses to any resource on the system the OS checks whether the user has sufficient privileges to access that resource.
§ Some examples of restrictions that exist for normal users are
o Process can use only the process space allocated to them
o Process can execute only for a maximum amount of time
o CPU registers and device control registers are not available to user processes
o Users can access only limited sets of files.
Command-Interpreter system
OS usually provide an interface to the user to interact with the kernel. The user issues commands to the kernel via this interface. The OS checks whether the user has the sufficient rights to run that particular command and then executes the command for the user. Examples for this system are MS-DOS window for DOS (or windows) and Shell prompt for Unix system. Examples of commands are dir (for DOS) or ls (for Unix). Modern OS also provide GUI based screens which act as an interface to the OS, where instead of typing commands user can execute task, by moving mouse pointers and clicking on an icon.
Error-Handling System
While normal working of a computing system, many errors can occur. These errors could be Memory hardware error, CPU error, error in the I/o devices (example – error on tape, connection failure on network, no paper in printer) etc. a user program can cause an error by executing some wrong instructions like divide by zero arithmetic error. An important function of the OS is to track such errors and try to recover from such errors. This determines the stability of the system. An OS is more stable if it takes proper steps to ensure correct and consistent computing even in face of errors.