OPERATING SYSTEM(OPERATING SYSTEM AND FUNCTIONS)NOTES, Lecture notes of Operating Systems

COURSE-B.Tech.(C.S./I.T.) UNIT1-OPERATING SYSTEM AND FUNCTION SEMESTER-4 SEM

Typology: Lecture notes

2018/2019

Uploaded on 06/29/2019

akshat-jain-5
akshat-jain-5 🇮🇳

5

(3)

2 documents

1 / 13

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
UNIT I
Operating system and functions
An operating system is a program that acts as an intermediary between a user of a computer and the
computer hardware.
An operating system is a system software which may be viewed as an organized collection of
software consisting of procedure’s for operating a computer and providing an environment for
execution of programs.
The purpose of an operating system is to provide an environment in which a user can execute
programs.
The primary goal of an operating system is thus to make the computer system convenient to use.
A secondary goal is to use the computer hardware in an efficient manner.
OS is a resource allocator
Manages all resources
Decides between conflicting requests for efficient and fair resource use
OS is a control program
Controls execution of programs to prevent errors and improper use of the computer
Components of operating system
Process Management
A process is a program in execution. It is a unit of work within the system. Program is a
passive entity, process is an active entity.
Process needs resources to accomplish its task such as CPU, memory, I/O, files
Process termination requires reclaim of any reusable resources.
Typically system has many processes, some user, some operating system running
concurrently on one or more CPUs Concurrency by multiplexing the CPUs among the
processes / threads.
Process Management Activities The operating system is responsible for the following activities in
connection with process management:
Creating and deleting both user and system processes
Suspending and resuming processes
Providing mechanisms for process synchronization
pf3
pf4
pf5
pf8
pf9
pfa
pfd

Partial preview of the text

Download OPERATING SYSTEM(OPERATING SYSTEM AND FUNCTIONS)NOTES and more Lecture notes Operating Systems in PDF only on Docsity!

UNIT – I

Operating system and functions

An operating system is a program that acts as an intermediary between a user of a computer and the computer hardware. An operating system is a system software which may be viewed as an organized collection of software consisting of procedure’s for operating a computer and providing an environment for execution of programs. The purpose of an operating system is to provide an environment in which a user can execute programs. The primary goal of an operating system is thus to make the computer system convenient to use.

A secondary goal is to use the computer hardware in an efficient manner.

OS is a resource allocator Manages all resources Decides between conflicting requests for efficient and fair resource use

OS is a control program Controls execution of programs to prevent errors and improper use of the computer

Components of operating system

Process Management  A process is a program in execution. It is a unit of work within the system. Program is a passive entity, process is an active entity.  Process needs resources to accomplish its task such as CPU, memory, I/O, files  Process termination requires reclaim of any reusable resources.  Typically system has many processes, some user, some operating system running concurrently on one or more CPUs Concurrency by multiplexing the CPUs among the processes / threads.

Process Management Activities The operating system is responsible for the following activities in connection with process management:  Creating and deleting both user and system processes  Suspending and resuming processes  Providing mechanisms for process synchronization

 Providing mechanisms for process communication  Providing mechanisms for deadlock handling

Memory Management  To execute a program all (or part) of the instructions and data that is needed must be in memory.  Memory management determines what is in memory and when and thus optimizing CPU utilization and computer response to users. Memory management activities  Keeping track of which parts of memory are currently being used and by whom  Deciding which processes (or parts thereof) and data to move into and out of memory  Allocating and deallocating memory space as needed

Storage Management  OS provides uniform, logical view of information storage  Abstracts physical properties to logical storage unit - file  Each medium is controlled by device (i.e., disk drive, tape drive) Varying properties include access speed, capacity, data-transfer rate, access method (sequential or random)

File-System management  Files usually organized into directories  Access control on most systems to determine who can access what  OS activities include Creating and deleting files and directories  Primitives to manipulate files and directories  Mapping files onto secondary storage  Backup files onto stable (non-volatile) storage media

Device Management  Usually disks used to store data that does not fit in main memory or data that must be kept for a “long” period of time  Proper management is of central importance  Entire speed of computer operation hinges on disk subsystem and its algorithms  OS activities : - Free-space management Storage allocation Disk scheduling  Some storage need not be fast Tertiary storage includes optical storage, magnetic tape o Still must be managed – by OS or applications o Varies between WORM (write-once, read-many-times) and RW (read-write)

OPERATING SYSTEM SERVICES:

Operating systems provide an environment for execution of programs and services to programs and users One set of operating-system services provides functions that are helpful to the user:  User interface - Almost all operating systems have a user interface (UI).  Varies between Command-Line (CLI), Graphics User Interface (GUI), Batch  Program execution - The system must be able to load a program into memory and to run that program, end execution, either normally or abnormally (indicating error)  I/O operations - A running program may require I/O, which may involve a file or an I/O device  File-system manipulation - Programs need to read and write files and directories, create and delete them, search them, list file Information, permission management.

System Components

- Process Management A process is only ONE instant of a program in execution. There are many processes can be running the same program. The five major activities of an operating system in regard to process management are: - Creation and deletion of user and system processes. - Suspension and resumption of processes. - A mechanism for process synchronization. - A mechanism for process communication. - A mechanism for deadlock handling. - Main-Memory Management Main-Memory is a large array of words or bytes. Each word or byte has its own address. Main memory is a repository of quickly accessible data shared by the CPU and I/O devices. The major activities of an operating system in regard to memory-management are:  Keep track of which part of memory are currently being used and by whom.  Decide which processes are loaded into memory when memory space becomes available.  Allocate and deallocate memory space as needed. - File Management A file is a collected of related information defined by its creator. Computer can store files on the disk (secondary storage), which provide long term storage. - The creation and deletion of files. - The creation and deletion of directions. - The support of primitives for manipulating files and directions. - The mapping of files onto secondary storage. - The backup of files on stable storage media. - I/O System Management One of the purposes of an operating system is to hide the peculiarities of specific hardware devices from the user. systems have several levels of storage, including primary storage, secondary storage and cache storage. Instructions and data must be placed in primary storage or cache to be referenced by a running program. - Networking A distributed system is a collection of processors that do not sharememory, peripheral devices, or a clock. The processors communicate with one another through communication lines called network**.

  • Protection System** Protection refers to mechanism for controlling the access of programs, processes, or users to the resources defined by a computer system**.
  • Command Interpreter System** A command interpreter is an interface of the operating system with the user. The user gives commands with are executed by operating system (usually by turning them into system calls).

The Operating System as Resource Manager

A computer is a set of resources for the movement, storage, and processing of data and for the control of these functions. The OS is responsible for managing these resources.

  • The OS functions in the same way as ordinary computer software; that is, it is a program or suite of programs executed by the processor.
  • The OS frequently relinquishes control and must depend on the processor to allow it to regain control. Like other computer programs, the OS provides instructions for the processor. The key difference is in the intent of the program. The OS directs the processor in the use of the other system resources and in the timing of its execution of other programs. But in order for the processor to do any of these things, it must cease executing the OS program and execute other programs. Thus, the OS relinquishes control for the processor to do some “useful” work and then resumes control long enough to prepare the processor to do the next piece of work.

A portion of the OS is in main memory. This includes the kernel, or nucleus, which contains themost frequently used functions in the OS and, at a given time, other portions of the OS currently in use. The remainder of main memory contains user programs and data. The allocation of this resource (main memory) is controlled jointly by the OS and memory management hardware in the processor.The OS decides when an I/O device can be used by a program in execution and controls access to and use of files. The processor itself is a resource, and the OS must determine how much processor time is to be devoted to the execution of a particular user program. In the case of a multiple-processor system, this decision must span all of the processors.

Types of Operating Systems

Serial Processing

With the earliest computers, from the late 1940s to the mid-1950s, the programmer interacted directly with the computer hardware; there was no OS. These computers were run from a console consisting of display lights, toggle switches, some form of input device, and a printer. Programs in machine code were loaded via the input device (e.g., a card reader). If an error halted the program, the error condition was indicated by the lights. If the program proceeded to a normal completion, the output appeared on the printer. These early systems presented two main problems:

  • Scheduling : Most installations used a hardcopy sign-up sheet to reserve computer time. Typically, a user could sign up for a block of time in multiples of a half hour or so. A user might sign up for an hour and finish in 45 minutes; this would result in wasted computer processing time. On the other

The monitor performs a scheduling function. A batch of jobs is queued up, and jobs are executed as rapidly as possible, with no intervening idle time. The monitor improves job setup time as well. With each job, instructions are included in a primitive form of job control language (JCL). This is a special type of programming language used to provide instructions to the monitor. The monitor, or batch operating system, is simply a computer program. It relies on the ability of the processor to fetch instructions from various portions of main memory to alternately seize and relinquish control. Certain other hardware features are also desirable:

 Memory protection : Does not allow the memory area containing the monitor to be altered  Timer : Prevents a job from monopolizing the system Privileged instructions  Privileged instructions : Certain machine level instructions can only be executed by the monitor

Multiprogrammed Batch Systems Even with the automatic job sequencing provided by a simple batch operating system, the processor is often idle. The problem is that I/O devices are slow compared to the processor. When we have a single program, it is referred to as uniprogramming.

The processor spends a certain amount of time executing, until it reaches an I/O instruction. It must then wait until that I/O instruction concludes before proceeding. This inefficiency is not necessary. We know that there must be enough memory to hold the OS (resident monitor) and one user program. Suppose that there is room for the OS and two user programs. When one job needs to wait for I/O, the processor can switch to the other job, which is likely not waiting for I/O Furthermore, we might expand memory to hold three, four, or more programs and switch among all of them. The approach is known as multiprogramming , or multitasking. It is the central theme of modern operating systems.

The important features of a Multiprogramming OS are :  Main memory should be big enough to hold multiple programs in the memory.  When the CPU is taken away from a process, it is necessary to save the current contents of different registers in CPU at that time so that the program may resume again from where it left off.  Memory protection should be provided so that the programs do not interfere with each other.  Proper mixture of CPU bound and I/O bound programs.

Time-Sharing Systems With the use of multiprogramming, batch processing can be quite efficient. However, for many jobs, it is desirable to provide a mode in which the user interacts directly with the computer. Indeed, for some jobs, such as transaction processing, an interactive mode is essential. Just as multiprogramming allows the processor to handle multiple batch jobs at a time, multiprogramming can also be used to handle multiple interactive jobs. In this latter case, the technique is referred to as time sharing, because processor time is shared among multiple users. In a time-sharing system, multiple users simultaneously access the system through terminals, with the OS interleaving the execution of each user program in a short burst or quantum of computation. Thus, if there are n users actively requesting service at one time, each user will only see on the average 1/n of the effective computer capacity, not counting OS overhead. However, given the relatively slow human reaction time, the response time on a properly designed system should be similar to that on a dedicated computer.

Multiprocessor Systems Multiprocessor systems (also known as parallel systems or multicore systems) have two or more processors in close communication, sharing the computer bus and sometimes the clock, memory, and peripheral devices. Multiprocessor systems first appeared prominently appeared in servers and have since migrated to desktop and laptop systems. Recently, multiple processors have appeared on mobile devices such as smart phones and tablet computers. Multiprocessor systems have three main advantages:

  1. Increased throughput. By increasing the number of processors, more work can be done in less time. The speed-up ratio with N processors is not N, however; rather, it is less than N. When multiple processors cooperate on a task, a certain amount of overhead is incurred in keeping all the parts working correctly. This overhead, plus contention for shared resources, lowers the expected gain from additional processors. Similarly, N programmers working closely together do not produce N times the amount of work a single programmer would produce.
  2. Economy of scale. Multiprocessor systems can cost less than equivalent multiple single-processor systems, because they can share peripherals, mass storage, and power supplies. If several programs operate on the same set of data, it is cheaper to store those data on one disk and to have all the processors share them than to have many computers with local disks and many copies of the data.
  3. Increased reliability. If functions can be distributed properly among several processors, then the failure of one processor will not halt the system, only slow it down. If we have ten processors and one fails, then each of the remaining nine processors can pick up a share of the work of the failed processor. Thus, the entire system runs only 10 percent slower, rather than failing altogether.

Increased reliability of a computer system is crucial in many applications. The ability to continue providing service proportional to the level of surviving hardware is called graceful degradation. Some systems go beyond graceful degradation and are called fault tolerant, because they can suffer a failure of any single component and still continue operation. The multiple-processor systems in use today are of two types: Asymmetric multiprocessing : in which each processor is assigned a specific task. A boss processor controls the system; the other processors either look to the boss for instruction or have predefined tasks. This scheme defines a boss–worker relationship. The boss processor schedules and allocates work to the worker processors. Symmetric multiprocessing (SMP), in which each processor performs all tasks within the operating system. SMP means that all processors are peers; no boss–worker relationship exists between processors.

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

Operating System Structure

Simple Structure : A system as large and complex as a modern operating system must be engineered carefully if it is to function properly and be modified easily. A common approach is to partition the task into small components, or modules, rather than have one monolithic system. Each of these modules should be

a well-defined portion of the system, with carefully defined inputs, outputs, and functions.

MS-DOS

  • written to provide the most functionality in the least space
    • not divided into modules
    • Although MS-DOS has some structure, its interfaces and levels of functionality are not well separated

UNIX

  • limited by hardware functionality, the original UNIX operating system had limited structuring. The UNIX OS consists of two separable parts. o Systems programs o The kernel
  • Consists of everything below the system-call interface and above the physical hardware
  • Provides the file system, CPU scheduling, memory management, and other operating- system functions; a large number of functions for one level

Layered Approach

The operating system is divided into a number of layers (levels), each built on top of lower layers. The bottom layer (layer 0), is the hardware; the highest (layer N) is the user interface. With modularity, layers are selected such that each uses functions (operations) and services of only lower-level layers

System Calls

  • System calls provide the interface between a running program and the operating system.
    • Generally available as assembly-language instructions.
    • Languages defined to replace assembly language for systems programming allow system calls to be made directly (e.g., C. Bliss, PL/360)
  • Three general methods are used to pass parameters between a running program and the operating system. - Pass parameters in registers. - Store the parameters in a table in memory, and the table address is passed as a parameter in a register. - Push (store) the parameters onto the stack by the program, and pop off the stack by operating system

Use of system call to do an I/O