If you go to a country whose native language you don’t know, what would you need to communicate with locals? Of course, an interpreter/translator. The operating system plays the same role between you and the computer. An operating system converts 1s and 0s values into a readable language that you can understand.
There are some very critical functions of OS without which you cannot even start a computer system.
What is an Operating System?
An Operating System (OS) is an interface between a computer user and computer hardware. An operating system is a collection of software that manages computer hardware and provides services for programs. It performs all the basic tasks like file management, memory management, process management, handling input and output, and controlling peripheral devices such as disk drives, keyboards, mouse, and printers.
Get Instant Access To
Coding For Kids eBook
A must read for every parent
Functions of OS
Following are some of the important functions of an operating system.
Memory Management is the process of controlling and coordinating computer memory, assigning portions known as blocks to various running programs to optimize the overall performance of the system.
It is the most important function of an operating system that manages primary memory. It helps processes to move back and forward between the main memory and execution disk. It helps the OS to keep track of every memory location, irrespective of whether it is allocated to some process or it remains free.
Why is memory management needed?
Following are the reasons for using memory management:
- It allows you to check how much memory needs to be allocated to processes that decide which processor should get memory at what time.
- Tracks whenever inventory gets freed or unallocated. According to it will update the status.
- It allocates the space to application routines.
- It also makes sure that these applications do not interfere with each other.
- Helps protect different processes from each other
- It places the programs in memory so that memory is utilized to its full extent.
To manage the memory efficiently, several techniques called Memory Management Techniques are used. Some of the most commonly used memory management techniques are:
Single Contiguous Allocation
It is the easiest memory management technique. In this method, all types of computer memory except a small portion that is reserved for the OS are available for one application. For example, MS-DOS operating system allocates memory in this way. An embedded system also runs on a single application.
It divides primary memory into various memory partitions, which are mostly contiguous areas of memory. Every partition stores all the information for a specific task or job. This method consists of allotting a partition to a job when it starts & unallocated it when it ends.
Paged Memory Management
This method divides the computer’s main memory into fixed-size units known as page frames. This hardware memory management unit maps pages into frames which should be allocated on a page basis.
Segmented Memory Management
Segmented memory is the only memory management method that does not provide the user’s program with a linear and contiguous address space.
Segments need hardware support in the form of a segment table. It contains the physical address of the section in memory, size, and other data like access protection bits and status.
In the case of a multiprogramming environment system gets multiple programs for execution and the operating system has to decide which program should be sent to the CPU for execution and for how much time. This process is called process scheduling in which the operating system decides which process needs to get into the CPU for execution and how much time span is required.
Assigning and de-assigning of the process is in charge of the operating system. CPU can execute one single process at a time so its selection is done by the operating system. The operating system uses a separate program to hold the status of the processor to provide information about is it free or busy in process execution. The traffic controller is used to keep the processor’s status information.
If the processor or CPU already has a process that is currently being executed, then the operating system does not let any other process get into the CPU for execution in this condition process sets into a wait condition. Assigning a processor or CPU to a process is called processor allocation. When a CPU executes a process it has to deallocate that process.
The process of completion of a program or process under the execution of CUP is called as deallocation of the processor because the processor transfers the processed information to the user. In this case, the processor gets free from the process and is ready to get a new process for execution. In the case of processor management operating system performs the following activities:
- It keeps the track of processor status and the processor itself. (The program which is responsible for this task is called as traffic controller)
- Allocates the processor or CPU to a Process.
- Deallocates the processor or CPU by a process.
Structure of a Process
Following is the structure of a process.
- Stack: The Stack stores temporary data like function parameters, returns addresses, and local variables.
- Heap: It Allocates memory, which may be processed during its run time.
- Data: It contains the variable.
- Text: The text Section includes the current activity, which is represented by the value of the Program Counter.
A process state is a condition of the process at a specific instant of time. It also defines the current position of the process. Every process can be in either of the following seven states:
- New: The new process is created when a specific program calls from secondary memory/ hard disk to primary memory/ RAM.
- Ready: In a ready state, the process should be loaded into the primary memory, which is ready for execution.
- Waiting: The process is waiting for the allocation of CPU time and other resources for execution.
- Executing: The process is an execution state.
- Blocked: It is a time interval when a process is waiting for an event like I/O operations to complete.
- Suspended: Suspended state defines the time when a process is ready for execution but has not been placed in the ready queue by OS.
- Terminated: Terminated state specifies the time when a process is terminated.
After completing every step, all the resources are used by a process, and memory becomes free.
Representation of a Process
Every process is represented in the operating system by a process control block (PCB), which is also called a task control block. Here, are the important components of PCB:
- Process state: A process can be new, ready, running, waiting, etc.
- Program counter: The program counter lets you know the address of the next instruction, which should be executed for that process.
- CPU registers: This component includes accumulators, index and general-purpose registers, and information of condition code.
- CPU scheduling information: This component includes a process priority, pointers for scheduling queues, and various other scheduling parameters.
- Accounting and business information: It includes the amount of CPU and time utilities like real-time used, job or process numbers, etc.
- Memory-management information: This information includes the value of the base and limit registers, the page, or segment tables. This depends on the memory system, which is used by the operating system.
- I/O status information: This block includes a list of open files, the list of I/O devices that are allocated to the process, etc.
Device management in the operating system implies the management of the I/O devices such as a keyboard, magnetic tape, disk, printer, microphone, USB ports, scanner, camcorder, etc. as well as the supporting units like control channels. The basics of I/O devices can fall into 3 categories:
- Block device: It stores information in fixed-size blocks, each one with its address. e.g., disks.
- Character device: Delivers or accepts a stream of characters. The individual characters are not addressable. For example printers, keyboards, etc.
- Network device: For transmitting data packets.
Functions of Device Management in the Operating System
An operating system or the OS manages communication with the devices through their respective drivers. The operating system component provides a uniform interface to access devices of varied physical attributes. For device management in an operating system:
- Keep tracks of all devices and the program which is responsible to perform this is called the I/O controller.
- Monitoring the status of each device such as storage drivers, printers, and other peripheral devices.
- Enforcing preset policies and taking a decision which process gets the device when and for how long.
- Allocates and efficiently deallocates the device. De-allocating them at two levels: at the process level when the I/O command has been executed and the device is temporarily released, and at the job level, when the job is finished and the device is permanently released.
- Optimizes the performance of individual devices.
Types of Devices
The OS peripheral devices can be categorized into 3: Dedicated, Shared, and Virtual. The differences among them are the functions of the characteristics of the devices as well as how they are managed by the Device Manager.
- Dedicated Devices: Such type of devices is dedicated or assigned to only one job at a time until that job releases them. Devices like printers, tape drivers, plotters, etc. demand such allocation scheme since it would be awkward if several users share them at the same point in time. The disadvantage of such kinds of devices is the inefficiency resulting from the allocation of the device to a single user for the entire duration of job execution even though the device is not put to use 100% of the time.
- Shared Devices: These devices can be allocated to several processes. A disk can be shared among several processes at the same time by interleaving their requests. The interleaving is carefully controlled by the Device Manager and all issues must be resolved based on predetermined policies.
- Virtual Devices: These devices are the combination of the first two types and they are dedicated devices that are transformed into shared devices. For example, a printer converted into a shareable device via spooling program which re-routes all the print requests to a disk. A print job is not sent straight to the printer, instead, it goes to the disk(spool) until it is fully prepared with all the necessary sequences and formatting, then it goes to the printers. This technique can transform one printer into several virtual printers which leads to better performance and use.
File management is one of the basic and important features of an operating system. The operating system is used to manage files of a computer system. All the files with different extensions are managed by the operating system.
A file is a collection of specific information stored in the memory of a computer system. File management is defined as the process of manipulating files in a computer system, its management includes the process of creating, modifying, and deleting the files.
The following are some of the tasks performed by file management of operating system of any computer system:
- It helps to create new files in the computer system and placing them at specific locations.
- It helps in easily and quickly locating these files in a computer system.
- It makes the process of sharing the files among different users very easy and user-friendly.
- It helps to stores the files in separate folders known as directories. These directories help users to search files quickly or to manage the files according to their types of uses.
- It helps the user to modify the data of files or to modify the name of the file in the directories.
The file management of function in an operating system (OS) is based on the following concepts:
- File Attributes: It specifies the characteristics of the files such as type, date of last modification, size, location on disk, etc. file attributes help the user to understand the value and location of files. File attributes are one most important features. It is used to describe all the information regarding a particular file.
- File Operations: It specifies the task that can be performed on a file such as opening and closing of a file.
- File Access permission: It specifies the access permissions related to a file such as read and write.
- File Systems: It specifies the logical method of file storage in a computer system. Some of the commonly used file systems include FAT and NTFS.
Security refers to providing a protection system to computer system resources such as CPU, memory, disk, software programs, and most importantly data/information stored in the computer system. If a computer program is run by an unauthorized user, then he/she may cause severe damage to the computer or data stored in it. So a computer system must be protected against unauthorized access, malicious access to system memory, viruses, worms, etc.
- One Time passwords
- Program Threats
- System Threats
Authentication refers to identifying each user of the system and associating the executing programs with those users. It is the responsibility of the Operating System to create a protection system that ensures that a user who is running a particular program is authentic. Operating Systems generally identifies/authenticates users using the following three ways −
- Username / Password − User need to enter a registered username and password with Operating system to login into the system.
- User card/key − User need to punch card in card slot, or enter key generated by key generator in option provided by operating system to login into the system.
- User attribute – fingerprint/ eye retina pattern/ signature − User need to pass his/her attribute via designated input device used by operating system to login into the system.
One Time passwords
One-time passwords provide additional security along with normal authentication. In the One-Time Password system, a unique password is required every time user tries to login into the system. Once a one-time password is used, then it cannot be used again. One-time passwords are implemented in various ways.
- Random numbers − Users are provided cards having numbers printed along with corresponding alphabets. System asks for numbers corresponding to few alphabets randomly chosen.
- Secret key − User are provided a hardware device which can create a secret id mapped with user id. System asks for such secret id which is to be generated every time prior to login.
- Network password − Some commercial applications send one-time passwords to user on registered mobile/ email which is required to be entered prior to login.
The operating system’s processes and kernel do the designated task as instructed. If a user program made these processes do malicious tasks, then it is known as Program Threats. One of the common examples of a program threat is a program installed in a computer that can store and send user credentials via network to some hacker. Following is the list of some well-known program threats.
- Trojan Horse − Such program traps user login credentials and stores them to send to malicious user who can later on login to computer and can access system resources.
- Trap Door − If a program which is designed to work as required, have a security hole in its code and perform illegal action without knowledge of user then it is called to have a trap door.
- Logic Bomb − Logic bomb is a situation when a program misbehaves only when certain conditions met otherwise it works as a genuine program. It is harder to detect.
- Virus − Virus as name suggest can replicate themselves on computer system. They are highly dangerous and can modify/delete user files, crash systems. A virus is generatlly a small code embedded in a program. As user accesses the program, the virus starts getting embedded in other files/ programs and can make system unusable for user
System threats refer to misuse of system services and network connections to put users in trouble. System threats can be used to launch program threats on a complete network called a program attack. System threats create such an environment that operating system resources/ user files are misused. Following is the list of some well-known system threats.
- Worm − Worm is a process which can choked down a system performance by using system resources to extreme levels. A Worm process generates its multiple copies where each copy uses system resources, prevents all other processes to get required resources. Worms processes can even shut down an entire network.
- Port Scanning − Port scanning is a mechanism or means by which a hacker can detects system vulnerabilities to make an attack on the system.
- Denial of Service − Denial of service attacks normally prevents user to make legitimate use of the system. For example, a user may not be able to use internet if denial of service attacks browser’s content settings.