Introduction to Operating Systems: Lecture Notes, Study notes of Operating Systems

A brief introduction to Operating System

Typology: Study notes

2018/2019

Uploaded on 12/05/2019

johnwanjama
johnwanjama 🇰🇪

2 documents

1 / 16

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
[Mr. Edwin Ireri]
Page 1
Introduction to Operating System
EDWIN IRERI
KYU
Lecture Notes on Operating System
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff

Partial preview of the text

Download Introduction to Operating Systems: Lecture Notes and more Study notes Operating Systems in PDF only on Docsity!

Introduction to Operating System

EDWIN IRERI

KYU

Lecture Notes on Operating System

Operating system Objectives

Computer System

An operating system (OS) is a set of programs that control the

execution of application programs and act as an intermediary between

a user of a computer and the computer hardware. OS is software that

manages the computer hardware as well as providing an environment

for application programs to run.

Examples of OS are: Windows, Windows/NT, OS/2 and MacOS.

The objectives of OS are: (1) To make the computer system convenient and easy to use for the user. (2) To use the computer hardware in an efficient way. (3) To execute user programs and make solving user problems easier.

A computer system can be divided into four components: the

hardware, the operating system, the application programs and the

users. The abstract view of system components is shown in figure 1.

1. Hardware : such as CPU, memory and I/O devices. 2. Operating system : provides the means of proper use of the hardware in the operations of the computer system, it is similar to government. 3. Application programs : solve the computing problems of the user, such as : compilers, database systems and web browsers. 4. Users: peoples, machine, or other computer. Introduction to operating

and to start executing that system. To accomplish this goal, the bootstrap program must locate and load into memory the operating system kernel. The operating system then starts executing the first process, such as "init," and waits for some event to occur. Figure 2

2. Storage Structure

Computer programs must be in main memory (also called RAM) to be executed. Main memory is the only large storage area that the processor can access directly. It forms an array of memory words. Each word has its own address. Interaction is achieved through a sequence of load or store instructions to specific memory addresses. The load instruction moves a word from main memory to an internal register within the CPU, whereas the store instruction moves the content of a register to main memory. The instruction-execution cycle includes:

  1. Fetches an instruction from memory and stores that instruction in the instruction register. And increment the PC register.
  2. Decode the instruction and may cause operands to be fetched from memory and stored in some internal register.
  3. Execute the instruction and store the result in memory.

3. I/O Structure

3. I/O Structure

The programs and data are not resided in main memory permanently for the following two reasons:

  1. Main memory is usually too small to store all needed programs and. Data permanently.
  2. Main memory is a volatile storage device that loses its contents when power is turned off or otherwise lost. Thus, most computer systems provide secondary storage as an extension of main memory to hold large quantities of data permanently. The wide variety of storage systems in a computer system can be organized in a hierarchy (figure 2). The main differences among the various storage systems lie in speed, cost, size, and volatility. The higher levels are expensive, but they are fast. Figure 3: Storage device hierarchy A computer system consists of CPUs and multiple device controllers that are connected through a common bus. The device controller is responsible for moving the data between the peripheral devices that it controls and its local

Operating system Functions

Operating systems have been evolving through the years. Following table shows the history of OS. OS performs many functions such as:

  1. Implementing user interface.
  2. Sharing HW among users.
  3. Allowing users to share data among themselves.
  4. Preventing users from interfering with one another.
  5. Scheduling resource among users.
  6. Facilitating I/O operations.
  7. Recovering from errors.
  8. Accounting for resource storage.
  9. Facilitating parallel operations.
  10. Organizing data for secure and rapid access. 11.Handling network communications.

Operating system History

The main categories of modern OS may be classified into three groups which are distinguished by the nature of interaction that takes place between the computer and the user:

1. Batch system

In this type of OS, users submit jobs on regular schedule (e.g. daily, weekly, monthly) to a central place where the user of such system did not interact directly with computer system. To speed up the processing, jobs with similar needs were batched together and were run through the computer as a group. Thus, the programmer would leave the programs with the operator. The output from each job would send to the appropriate programmer. The major task of this type was to transfer control automatically from one job to the next. Disadvantages of Batch System

1. Turnaround time can be large from user standpoint. 2. Difficult to debug program. 2. Time-Sharing System This type of OS provides on-line communication between the user and the system, the user gives his instructions directly and receives intermediate response, and therefore it called interactive system. The time sharing system allows many user simultaneously share the computer system. The CPU is multiplexed rapidly among several programs, which are kept in memory and on disk. A program swapped in and out of memory to the disk. Time sharing system reduces the CPU ideal time. The disadvantage is more complex.

Operating system Categories

4. Multiprogramming In multiprogramming several programs are kept in main memory at the same time, and the CPU is switching between them , thus the CPU always has a program to be execute. The OS begins to execute one program from memory, if this program need wait such as an I/O operation, the OS switches to another program. Multiprogramming increases CPU utilization. Multiprogramming system provide an environment in which the various system resources are utilized effectively, but they do not provide for user interaction with the computer system. Advantages a) High CPU utilization. b) It appears that many programs are allotted CPU almost simultaneously. Disadvantages a) CPU scheduling is requires. b) To accommodate many jobs in memory, memory management is required. 5. Parallel system There are more than on processor in the system. These processors share the computer bus, clock, memory and I/O devices. The advantage is to increase throughput (the number of programs completed in time unit).

6. Distributed system Distribute the computation among several physical processors. It involves connecting 2 or more independent computer systems via communication link. So, each processor has its own O.S. and local memory; processors communicate with one another through various communications lines, such as high-speed buses or telephone lines. Advantages of distributed systems: a) Resources Sharing – You can share files and printers. b) Computation speed up – A job can be partitioned so that each processor can do a portion concurrently (load sharing). c) Reliability – If one processor failed the rest still can function with no problem. d) Communications – Such as electronic mail, ftp 7. Personal computer Personal computers – computer system dedicated to a single user. PC operating systems were neither multi-user nor multi-tasking. The goal of PC operating systems were to maximize user convenience and responsiveness instead of maximizing CPU and I/O utilization. •Examples: Microsoft Windows and Apple Macintosh

Operating system operations

2. Accounting: For account billing and usage statistics.

3. Protection: Ensure access to system resource is controlled.

Modern operating systems are interrupt driven. If there are no processes to execute, no I/O devices to service, and no users to whom to respond, an operating system will sit quietly, waiting for something to happen. Events are almost always signaled by the occurrence of an interrupt or a trap. A trap is a software-generated interrupt caused either by an error (for example, division by zero or invalid memory access) or by a specific request from a user program that an operating-system service be performed. For each type of interrupt, separate segments of code in the operating system determine what action should be taken. An interrupt service routine is provided that is responsible for dealing with the interrupt. Since the operating system and the users share the hardware and software resources of the computer system, we need to make sure that an error in a user program could cause problems only for the one program that was running. With sharing, many processes could be adversely affected by a bug in one program. A properly designed operating system must ensure that an incorrect (or malicious) program cannot cause other programs to execute incorrectly. A) Dual-Mode Operation We must be able to distinguish between the execution of operating-system code and user defined code. The approach is to separate the two modes of operation : user mode and kernel mode (also called supervisor mode, system mode, or privileged mode). A bit, called the mode bit is added to the hardware of the computer to indicate the current mode: kernel (0) or user (1). The dual mode of operation provides us with the means for protecting the operating system from errant users-and errant users from one another.

Management

1. Process Management Memory Management System calls provide the means for a user program to ask the operating system to perform tasks reserved for the operating system on the user program's behalf. B) Protection CPU To ensure that the operating system maintains must control over the CPU. We must prevent a user program from getting stuck in an infinite loop or not calling system services and never returning control to the operating system. To accomplish this goal, we can use a timer. A timer can be set to interrupt the computer after a specified fixed or variable period. The operating system components are : In multiprogramming environment, OS decides which process gets the processor when and how much time. The operating system is responsible for the following activities in regard to process management:

  1. Creating and deleting both user and system processes
  2. Suspending and resuming processes
  3. Providing mechanisms for process synchronization
  4. Providing mechanisms for process communication
  5. Providing mechanisms for deadlock handling Main memory is a large array of words or bytes where each word or byte has its own address. The operating system is responsible for the following activities in regard to memory management:
  6. Keeping track of which parts of memory are currently being used and by whom
  7. Deciding which processes (or parts thereof) and data to move into and out of memory Operating System Components

Example system call sequence System program provide basic function to users, so that they don’t need to write their own environment for program development (editors, compilers) and program execution (shells). Protection refers to mechanism that control the access of programs or users to the both system and resources. The protection mechanism must:

  1. Distinguish between unauthorized and authorized user.
  2. Specify the control to be imposed.
  3. Provide a means of enforcement. Security measures are responsible for defending a computer system from external or internal attack. Acquire input filename Write prompt to screen Accept input Acquire output filename Write prompt to screen Accept input Open the input file If file does not exist, abort Create output file If file exist, abort Loop Read from input file Write to output file Until read fail Close output file Write completion message on screen Terminate normally Protection and security