Introduction to Operating System
 Definition:- An operating system acts as an intermediary between the user
    of a computer and computer hardware. It is an interface between computer
    hardware and user. Examples are Linux, Unix, Windows 11,          MS DOS,
    Android, macOS and iOS.
   The purpose of an operating system is to provide an environment in which a
    user can execute programs conveniently and efficiently.
   An operating system is software that manages computer hardware and
    software. The hardware must provide appropriate mechanisms to ensure the
    correct operation of the computer system and to prevent user programs
    from interfering with the proper operation of the system.
   Operating system is a program running at all times on the computer (usually
    called the kernel), with all else being application programs.
 Structure of Operating System
A system structure for an operating system is like the blueprint of how an OS is
organized and how its different parts interact with each other. Because operating
systems have complex structures, we want a structure that is easy to understand
so that we can adapt an operating system to meet our specific needs. Similar to
how we break down larger problems into smaller, more manageable subproblems,
building an operating system in pieces is simpler. The operating system is a
component of every segment.
   Storage Structure in Operating Systems
There are two types of storage devices:-
Primary / Volatile Storage Device : It loses its contents when the power of the
device is removed.
Secondary / Non-Volatile Storage device : It does not loses its contents when
the power is removed. It holds all the data when the power is removed.
   Secondary Storage is used as an extension of main memory.
   Secondary storage devices can hold the data permanently.
    Storage devices consists of Registers, Cache, Main-Memory, Electronic-
    Disk, Magnetic-Disk, Optical-Disk, Magnetic-Tapes.
   Each storage system provides the basic system of storing a data and
    holding the data until it is retrieved at a later time.
   All the storage devices differ in speed, cost, size and volatility.
   The most common Secondary-storage device is a Magnetic-disk, which
    provides storage for both programs and data.
  Functions of Operating System
The main goal of the Operating System is to make the computer environment
more convenient to use and the Secondary goal is to use the resources most
efficiently.
  1. Memory Management
  It keeps track of primary memory, i.e., which bytes of memory are used by
   which user program. The memory addresses that have already been
   allocated and the memory addresses of the memory that has not yet been
   used.
  In multiprogramming, the OS decides the order in which processes are
   granted memory access, and for how long.
  It Allocates the memory to a process when the process requests it and
   deallocates the memory when the process has terminated or is performing
   an I/O operation.
 2. Processor Management
  In a multi-programming environment, the OS decides the order in which
   processes have access to the processor, and how much processing time
   each process has.
  This function of OS is called Process Scheduling.
  An operating system manages the processor’s work by allocating various
   jobs to it and ensuring that each process receives enough time from the
   processor                   to              function               properly.
   Keeps track of the status of processes.
  Allocates the processor to a process. De-allocates processor when a process
   is no longer required.
 3. Device Management
  Keeps track of all devices connected to the system.
  Decide which process gets access to a certain device and for how long.
  Allocates devices effectively and efficiently. Deallocates devices when they
   are no longer required.
  There are various input and output devices. An OS controls the working of
   these input-output devices.
  It receives the requests from these devices, performs a specific task, and
   communicates back to the requesting process.
 4. File Management
  It keeps track of where information is stored, user access settings, the status
   of every file.
  These facilities are collectively known as the file system.
  An OS keeps track of information regarding the creation, deletion, transfer,
   copy, and storage of files in an organized way.
  It also maintains the integrity of the data stored in these files, including the
   file directory structure, by protecting against unauthorized access.
 Types of Operating System
 1. Batch operating system
  The users of a batch operating system do not interact with the computer
    directly.
 Each user prepares his job on an off-line device like punch cards and
  submits it to the computer operator.
 To speed up processing, jobs with similar needs are batched together and
  run as a group.
 The programmers leave their programs with the operator and the operator
  then sorts the programs with similar requirements into batches.
 The problems with Batch Systems are as follows −
 Lack of interaction between the user and the job.
 CPU is often idle, because the speed of the mechanical I/O devices is slower
  than the CPU.
 Difficult to provide the desired priority.
2. Time-sharing operating systems
 Time-sharing or multitasking is a logical extension of multiprogramming.
   Processor's time which is shared among multiple users simultaneously is
   termed as time-sharing.
 The main difference between Multi-programming Systems and Time-Sharing
   Systems is that in case of Multi-programming systems, the objective is to
   maximize processor use, whereas in Time-Sharing Systems, the objective is
   to minimize response time.
 Multiple jobs are executed by the CPU by switching between them, but the
   switches occur so frequently.
 The operating system uses CPU scheduling and multiprogramming to
   provide each user with a small portion of a time.
    Advantages
   Provides the advantage of quick response.
   Avoids duplication of software.
   Reduces CPU idle time.
      Disadvantages
   Problem of reliability.
   Question of security and integrity of user programs and data.
   Problem of data communication.
3. Distributed operating System
 Distributed systems use multiple central servers to serve multiple real-time
   applications and multiple users.
 Data processing jobs are distributed among the servers accordingly.
 The servers communicate with one another through various communication
   lines (such as high-speed buses or telephone lines).
 These are referred as loosely coupled systems or distributed systems.
 Servers in a distributed system may vary in function. These servers are
   referred as sites, nodes, computers, and so on.
The advantages of distributed systems are as follows −
 With resource sharing facility, a user at one site may be able to use the
   resources available at another.
 Speedup the exchange of data with one another via electronic mail.
 If one site fails in a distributed system, the remaining sites can potentially
   continue operating.
 Better service to the customers.
 Reduction of the load on the host computer.
 Reduction of delays in data processing.
4. Real Time operating System
 A real-time system is defined as a data processing system in which the time
   interval required to process and respond to inputs is so small that it controls
   the environment.
 The time taken by the system to respond to an input and display of required
   updated information is termed as the response time. So in this method,
   the response time is very less as compared to online processing.
 Real-time systems are used when there are rigid time requirements on the
   operation of a processor or the flow of data and real-time systems can be
   used as a control device in a dedicated application.
 A real-time operating system must have well-defined, fixed time constraints,
   otherwise the system will fail.
 For example, Scientific experiments, medical imaging systems, industrial
   control systems, weapon systems, robots, air traffic control systems, etc.
There are two types of real-time operating systems.
Hard real-time systems guarantee that critical tasks complete on time. In
hard real-time systems, secondary storage is limited or missing and the data is
stored in ROM. In these systems, virtual memory is almost never found.
Soft real-time systems are less restrictive. A critical real-time        task gets
priority over other tasks and retains the priority until it completes.   Soft real-
time systems have limited utility than hard real-time systems. For        example,
multimedia, virtual reality, Advanced Scientific Projects like            undersea
exploration and planetary
5. Multiprogramming in Operating System
    As the name suggests, Multiprogramming means more than one program
     can be active at the same time.
    Before the operating system concept, only one program was to be loaded
     at a time and run.
    These systems were not efficient as the CPU was not used efficiently. For
     example, in a single-tasking system, the CPU is not used if the current
     program waits for some input/output to finish.
    The idea of multiprogramming is to assign CPUs to other processes while
     the current process might not be finished. This has the below advantages.
    The user gets the feeling that he/she can run multiple applications on a
     single CPU even if the CPU is running one process at a time.
    All modern operating systems like MS Windows, Linux, etc are
     multiprogramming operating systems.
 System Calls in OS
 A system call is a programmatic way in which a computer program requests
  a service from the kernel of the operating system it is executed on.
 A system call is a way for programs to interact with the operating
  system.
 A computer program makes a system call when it requests the operating
  system’s kernel.
 System call provides the services of the operating system to the user
  programs via the Application Program Interface(API).
 System calls are the only entry points into the kernel system and are
  executed in kernel mode.
 A user program can interact with the operating system using a system call.
            Process         System Call
                            CreateProcess()
             Process
                            ExitProcess()
             Control
                            WaitForSingleObject()
                            CreateFile()
             File
                            ReadFile()
             manipulation
                            WriteFile()
             Device         SetConsoleMode()
             Management
               Process          System Call
                                ReadConsole()
                                WriteConsole()
                                GetCurrentProcessID()
                Information
                                SetTimer()
                Maintenance
                                Sleep()
                                CreatePipe()
                Communicati
                                CreateFileMapping()
                on
                                MapViewOfFile()
                Protection      SetFileSecurity()
                                InitializeSecurityDescript
                                or()
                                SetSecurityDescriptorgro
                                up()
  Spooling
 Spooling is an acronym for simultaneous peripheral operation online.
 Spooling is the process of temporary storage of data for use and execution by a
  device, program, or system.
 Data is sent to and stored in main memory or other volatile storage until it is
  requested for execution by a program or computer.
 Spooling makes use of the disc as a large buffer to send data to printers and
  other devices.
 It uses the FIFO(First In First Out) strategy to retrieve the stored jobs in the
  spool, and that creates a synchronization preventing the output to be
  completely mixed together.
  Booting
  Booting is basically the process of starting the computer. When the CPU is first
  switched on it has nothing inside the Memory. In order to start the Computer,
  load the Operating System into the Main Memory and then Computer is ready
  to take commands from the User.
  Booting happens when you start the computer. This happens when we turned
  ON the power or the computer restarts. The system BIOS (Basic Input/Output
  System) makes the peripheral devices active. Further, it requires that the boot
  device loads the operating system into the main memory.
Questions
   1.   Define operating? Explain different types of operating system.
   2.   Explain the different functions of operating system?
   3.   Explain System calls.
   4.   Explain the structure of operating system.
   5.   Explain the storage structure of operating system.
   6.   Define a)Spooling       b)Booting         c)Buffer
   7.   Expand a) BIOS       b) SPOOL
                                **********************