Introduction to Operating System (OS) for Beginners

0
1569

operating systemUnderstanding operating system would definitely be a worthwhile use of your time, as you’ll understand what powers and enables the gadgets that make up the world today. This post would serve as an introduction to OS for beginners.

  1. What is the Operating System?

An operating system is an intermediary between users and computer hardware. The instructions you give to a computer is performed due to an Operating system. It is a software that manages the computer hardware. It runs at all times when the computer is powered on.

2. What are most used Operating Systems?

Operating systems powers Laptops, Personal computers and also gigantic servers which operate the Wall Street, the Web and so on. Windows by Microsoft is the choice for personal and official use. MacOS by Apple comes second to Windows in terms of adoption. Linux, on open source OS, is most preferred by computer programmers and is also used to run huge servers.

3. What are the types of OS?

As computers evolved from Vaccum Tubes to Transistors to Integrated Circuits to VLSI, the OS has also undergone significant changes to keep up with the computers.

  • Batch OS– This OS does not directly work with the computer. An operator (human) takes similar jobs having the same requirement and group them into batches. The batches are then given to the CPU for execution. The efficiency of the operating system depends on the operator to group the jobs.
  • Time-sharing OS – Here the tasks are given a time slice/quantum to execute. This allows many users to share the computer resources in a fair manner and CPU utilization is increased. Tasks can be from a single user/ multiple users. eg. UNIX
  • Distributed OS– Effectively, manages a group of different computers (each with own memory and CPU) and make them appear to be a single computer. This allows shared access to files, printers and applications.
  • Network OS– The individual computers have a common server and computers running in the different operating systems can participate in a common network. Remote access is possible like in case of distributed systems. Presence of server enhances the security of the whole network. They are tightly coupled.
  • Real-time OS — As the name suggests, they are meant for real-time devices where time requirements are very strict like air traffic control, missile control and even in autonomous cars. Here delays could lead to failures.

4. What are the programs and processes?

There is a succinct difference between the two terms. A computer program is a set of instructions that perform a specific task when executed. A process is a program in execution. That is a python program written for a computation becomes a process when it is performing the action.

5. What are the functions of an OS?

functions of an OS

As we could see from the figure, OS is a software which coordinates with System SW(compilers, editors,..)and Application SW (run by users) and performs them using the Hardware. Following are the major functions of an OS :

  • Device Management — Communicates with devices via device drivers, Keeps track of them using I/O Controller, allocates them to processes.
  • Memory Management — allocates main memory /RAM ( CPU can access it fast and here programs are executed ) and keeps track of it.
  • Processor Management — Monitors processor (CPU) and process states and allocates the CPU to process in a scheduled way.
  • File Management — controls the file system(directories and files) and access to it.
  • Security — Provides authentication and prevents unauthorized access.

It also monitors the jobs and system performance.

6. What is the memory layout of a process?

A program loaded into the memory becomes a process, the memory layout consists of ─ stack, heap, text, and data.

7. What is scheduling?

In a system, multiple processes want to execute using the CPU. To manage the processor between them, the process manager (a component of OS) picks up the ready process and schedules it for execution. It has to remove an already running process — may be because it finished or it requires an Input/Output Device and is waiting for it or to let other processes have their share of CPU time. All this is based on certain algorithms.

The processes share the CPU using time multiplexing. Each process has a data structure called the PCB (Process Control Block) which contains information about itself, which would be used for scheduling. A Process could be in any state — ready or running or waiting.

8. What are some scheduling algorithms?

Process manager schedules different processes to be assigned to the CPU based on scheduling algorithms.

  • First-Come, First-Served (FCFS) Scheduling
  • Shortest-Job-First (SJF) Scheduling
  • Priority Scheduling
  • Shortest Remaining Time First (SRTF)
  • Round Robin(RR) Scheduling
  • Multiple-Level Queues Scheduling

These algorithms are either non-preemptive or preemptive. In Non-preemptive, once a process enters the running state, it cannot be removed from execution until it completes its allotted time. The preemptive scheduling is based on priority where the highest priority process is given CPU once it becomes ready, preempting any lower priority process.

9. What are the threads?

A thread or commonly referred to as a lightweight process is a path of execution within a process. A process can contain multiple threads. It is used to introduce parallelism, for example, when you visit Facebook, one thread pops up notification, one thread brings new posts in your feed, while one thread may display chats.

Threads of the same process share the code section and the data section.They are classified into user-level threads and kernel-level threads.

10. What is memory management?

Memory management is a function of the OS to load the programs into the main memory. Main memory is also known as RAM. The computer can operate on programs in RAM only. So every program to be executed and every file to be accessed must be copied from a storage device into main memory. It is called loading.

Swapping is the bringing in each process in main memory, running it for a while and then putting it back to the secondary memory/disk. It is used when there is not enough space in the RAM to hold all the process competing for CPU.

11. What is the virtual memory?

All process require RAM as we know. To address more memory than the amount physically installed on the system, the concept of virtual memory is introduced. This extra memory is actually a section of a hard disk that’s set up to emulate the computer’s RAM. It allows programs to be larger than physical memory. The MMU(Memory Management Unit) is used to translate virtual addresses into physical addresses.

12. What is caching?

Frequently accessed data from main memory is copied into faster storage system the cache. When data is required it is checked if present in the cache. If not, it is copied from RAM or disk into the cache for future access. This reduces the search time if that data is needed again. Cache is limited and cannot replace main memory because of its high cost.

13. What are interrupts?

An interrupt is a signal from a device attached to a computer(Hardware) or from a program within the computer (Software) that requires the immediate attention of the OS. Depending on the priority of the interrupt, the OS figures out what to do. It handles the interrupt by performing a code called the Interrupt Service Routine corresponding to each interrupt. Example, divide by zero causes an interrupt.

14. What is process synchronization?

On the basis of synchronization, processes are of two types:

  • Independent Process: Execution of one process does not affect the execution of other processes.
  • Cooperative Process: Execution of one process affects the execution of other processes. Since resources are shared here, process synchronization problems occur here.

Critical Section Problem

Critical section is a code segment that can be accessed by only one process at a time. It contains shared variables which need to be synchronized(all instances of the same variable must have the same value) to maintain consistency. To solve this problem, hardware or software such as mutex locks are used.

15. What is a deadlock?

A process may require resources to complete its functions. Resources are limited in nature in a system — they include both virtual(filesystems, network sockets …)and physical resources (memory, CPU, all external devices). Deadlock occurs when processes get locked because they are waiting for a resource which is held by another process and the other process wait for resources held by this process.

In the below figure, Process 1 wants Resource 2. But Resource 2 is assigned to Process 2. Process 2 wants Resource 1 but it is allocated to Process 1. So each process ends up blocking waiting for a resource. It’s almost a vicious cycle.

deadlock

16. What is the booting up?

To boot a computer is to load an OS into the computer’s main memory. Once the operating system is loaded (and, for example, on a PC, you see the initial Windows or Mac desktop screen), it’s ready for users to run applications.

17. Why are updates required on OS?

A source of frustration for most Windows users, we need to understand why exactly they are required.An update, often in the form of a patch or service pack, comes from the vendors, Microsoft for example, to address vulnerabilities with their existing products. Mostly, these patches fall into Security vulnerability fixes or Bug fixes and enhancements. Computers that didn’t update with the SMB patch were vulnerable to the Wannacry Ransomware attacks in 2017. So next time you get an update, it’s better to do it.

18. What is a mobile OS?

A mobile operating system is the software platform on top of which other programs can run on mobile devices. Mobile operating systems provide application access, manage cellular and wireless network connectivity, as well as phone access. The most popular ones are Android by Google which is open sourced and iOS by Apple.

Windows OS for mobile and BlackBerry OS also are mobile OS, but with minute market share.

Author: Amirtha Varshini A S