Introduction to Operating System

Introduction to Operating System

Application Software Perform specific tasks for the user.

System Software controls and operates the computer system, as well as provide a platform for application software to execute on.

An Operating System is a piece of software, and hardware that offers an environment in which the user may run his or her applications conveniently and efficiently by hiding the underlying complexity of the hardware and acting as a resource manager.

Why OS?

  1. What if there is no OS?

    • A large and complicated app. (Code for hardware interaction must be included in the app's codebase.)
    • Exploitation of resources by a single app.
    • There isn't any memory protection.
  2. What makes up an operating system?

    • System software collection

Program :

A program is an executable file that contains a collection of instructions that your computer can use to execute a certain task or action.

  • It's compiled code that's ready to run.
  • Stored in hard drive

Process :

The primary memory [RAM] of the computer stores the program that is now being executed.

A feature of the Operating System :

  • Access to the computer hardware.
  • Interaction between the user and the hardware of the computer.
  • Managing resources (AKA, Arbitration) (Memory, Device, File, Security, Process, and so on)
  • Hides the underlying complexity of the hardware. (Aka, Arbitration).
  • It simplifies application program execution by isolating and protecting them.

first .png

The Operating System gives you the tools you need to make the best use of your computer's resources.

OS Objectives:

  • Maximum Utilization of the CPU
  • Process hunger is reduced.
  • Higher priority job execution.

Operating Systems Types :

typesofos.png

  • Single process Operating Systems
    [MS DOS, 1981]
  • Batch - processing Operating Systems
    [ATLAS, Manchester Univ., late 1950s - early 1960s]
  • Multiprogramming Operating Systems
    [THE, Dijkstra, early 1960s]
  • Multitasking Operating Systems
    [CTSS, Mit, early 1960s]
  • Multi-processing Operating Systems
    [Windows NT]
  • Distributed Operating Systems
    [LOCUS]
  • Embedded Operating Systems [Linux and Symbian]
  • Real-time Operating Systems
    [ATCS]

Single process Operating Systems :

From the ready queue, only one process runs at a time.

Batch - processing Operating Systems :

  • To begin, the user prepares his job by punching cards.
  • Then, he submits the job to the computer operator.
  • The operator gathers work from various users and groups them into batches with comparable requirements.
  • Then, the operator sends each batch to the processor one by one.
  • The jobs in a batch are all run at the same time.

    Priorities cannot be set.

    May lead to starvation.

    In the case of I/O operations, the CPU may become ideal.

Work flow.png

Multiprogramming Operating Systems :

It improves CPU utilization by storing many tasks (code and data) in memory so that the CPU always has one to run in the event that one of the jobs becomes busy with I/O.

  • Simple CPU
  • Context switching for processes.
  • When the current process enters the wait state, the switch occurs.
  • CPU idle time reduces.

Multitasking Operating Systems :

It is a logical extension of multiprogramming.

  • Single CPU
  • Able to run more than one task simultaneously.
  • Time-sharing and context switching were used.
  • Makes you more responsive.
  • CPU idle time is reduced even more.

Multi-processing Operating Systems :

It denotes the presence of more than one CPU in a single machine.

  • Increases reliability, 1 CPU fails, other can work.
  • Increased throughput.
  • Task starvation is reduced (if one CPU is busy with one process, another can run on the other CPU).

Distributed Operating Systems :

  • OS manages many bunches of resources,

    [ >=1 CPUs, >=1 memory, >=1 GPUs, etc.]

  • Loosely connected autonomous, interconnected computer nodes.
  • Collection of independent, networked, communicating, and physically separate computational nodes.

Embedded OS :

It is a special-purpose computer with real-time computing capabilities that performs one or a few specific functions.

embedded os.png

Real-time Operating Systems :

  • Real-time error-free, computations within tight-time boundaries.
  • Air Traffic control system, ROBOTS, etc.

Thread :

  • Within a process, there is only one sequence stream.
  • In a process, an independent execution path.
  • It is a lightweight process.
  • Used to achieve parallelism by separating a process's task into separate execution paths.
  • For Example, Multiple tabs in a browser, or a text editor (when you are typing in an editor, spell checking, formatting of the text by multiple threads.)

Multi-tasking :

  • Multitasking is the process of performing multiple tasks at the same time.
  • Context switching is the concept of having multiple processes running at the same time.
  • The number of CPUs is 1.
  • There is memory and isolation protection. Each program that the CPU executes must have its own memory and resources allocated by the operating system.

Multi-Threading :

  • A process is divided into multiple sub-tasks called threads, each with its own execution path. this concept is called multi-threading.
  • The idea of having more than one thread. The context of the threads is shifted.
  • Number of CPU >=1
  • There is no memory segregation or protection, therefore resources are shared among threads in that process. - The operating system allocates memory to a process.

Thread Scheduling :

Threads are scheduled for execution according to their priority. Despite the fact that threads run within the runtime, the operating system assigns all threads processor time slices.

Thread Context Switching :

  • The OS saves the thread's current state and switches to another thread in the same process.
  • Doesn't include memory address space switching [but does include program counter, register, and stack]
  • Quick swapping
  • The cache state of the CPU is kept.

Process Context Switching :

  • The operating system saves the current state of the process and changes to another by restoring it.
  • Switching memory address space is included.
  • Switching is slow
  • The cache state of the CPU is flushed.

Kernel :

A kernel is the part of an operating system that interacts directly with hardware and conducts the most important functions.

  • Heart of OS/Core component.
  • The initial section of the operating system to load when it boots up.

User Space :

Apps do not have privileged access to the underlying hardware on which they run. It communicates with the kernel.

  • GUI [ Graphical User Interface ]

  • CLI [ Command Line Interface ]

A Shell, also known as a command interpreter, is a component of the operating system that receives and executes user commands.

Functions of Kernel :

1. Process Management :

  • Process and thread scheduling on the CPUs.
  • Both user and system processes are created and detected.
  • Processes that are suspended and resumed.
  • Providing synchronization or communication tools for processes.

2. Memory Management :

  • Assigning and releasing memory space as needed.
  • Keeping track of which chunk of memory is being used by which process at any given time.

3. File Management :

  • Adding and removing files.
  • Organize files by creating and removing directories.
  • mapping file into secondary storage.
  • support for backups to a reliable storage medium

4. I/O Management :

To regulate and manage I/O activities and devices Buffering, caching, and spooling are all methods for copying data between two devices.

  • Buffering

    • Within the same job.
    • Take, for example, Youtube video buffering.
  • Caching

    • Memory caching and web caching are two types of caching.
  • Spoiling

    • two jobs at different speeds
    • Eg. print spooling and mail spooling.

Types of kernels :

1. Monolithic kernel :

  • The kernel contains all functions.
  • Large and bulky.
  • The amount of memory required to run is considerable.
  • Less reliable, one module crash. -> the whole kernel down.
  • excellent performance due to rapid communication [Kernel mode overheads are lower than user-mode overheads]
  • For example, Linux, Unix, and Ms-DOS

2. Microkernel :

  • The kernel contains only the most important functionality.
    • Memory administration.
    • Process Control.
  • A smaller size