1 of 69

Introduction

DR. NOMAN ISLAM

2 of 69

Course Goals

  • This course will introduce you to the various components which comprise a modern operating system. Such components include processes and threads, memory management, and file systems (to name a few.) This course will be a mixture of both theory and practical study where we will complement theory with several examples showing how real operating systems work.
  • Text Book: Abraham Silberschatz and Peter Baer Galvin: Operating System Concepts, Addison-Wesley, 9th Edition

3 of 69

Week

Topic to be Covered

1

Introduction

2

Operating system Structures

3

System calls

4

Processes

5

Threads

6

Multithreading

7

CPU scheduling

8

CPU scheduling

 

Mid Term Examination

9

Process Synchronization

10

Deadlock Handling

11

Main Memory

12

Memory Management

13

File system Interface

14

Mass Storage Systems

15

Security and Protection

16

Final Assignment & Reviews

 

Final Examination

4 of 69

Introduction

  • An operating system is a program that manages a computer’s hardware
  • Acts as an intermediary between the computer user and the computer hardware

5 of 69

  • Mainframe operating systems are designed primarily to optimize utilization of hardware.
  • Personal computer (PC) operating systems support complex games, business applications, and everything in between.
  • Operating systems for mobile computers provide an environment in which a user can easily interface with the computer to execute programs.
  • Thus, some operating systems are designed to be convenient, others to be efficient, and others to be some combination of the two.

6 of 69

7 of 69

8 of 69

  • Four components: the hardware, the operating system, the application programs, and the users
  • The hardware—the central processing unit (CPU), the memory, and the input/output (I/O) devices—provides the basic computing resources for the system
  • The application programs—such as word processors, spreadsheets, compilers, and Web browsers—define the ways in which these resources are used to solve users’ computing problems.
  • The operating system controls the hardware and coordinates its use among the various application programs for the various users.

9 of 69

  • An operating system is similar to a government.
  • Like a government, it performs no useful function by itself.
  • It simply provides an environment with in which other programs can do useful work.

10 of 69

User View

  • Most computer users sit in front of a PC, consisting of a monitor, keyboard, mouse, and system unit
  • Such a system is designed for one user
  • The goal is to maximize the work (or play) that the user is performing.
  • Designed mostly for ease of use
  • such systems are optimized for the single-user experience rather than the requirements of multiple users.

11 of 69

  • In other cases, a user sits at a terminal connected to a mainframe or a minicomputer
  • Other users are accessing the same computer through other terminals.
  • These users share resources and may exchange information
  • Operating system in such cases is designed to maximize resource utilization

12 of 69

  • Work stations and servers
  • share resources such as networking and servers, including file, compute, and print servers
  • Their operating system is designed to compromise between individual usability and resource utilization

13 of 69

  • Recently, many varieties of mobile computers, such as smart phones and tablets, have come into fashion
  • Most mobile computers are standalone units for individual users
  • The user interface for mobile computers generally features a touch screen, where the user interacts with the system by pressing and swiping finger across the screen rather than using a physical keyboard and mouse.

14 of 69

  • Some computers have little or no user view
  • embedded computers in home devices and automobiles may have numeric keypads
  • May turn indicator lights on or off to show status
  • Their operating systems are designed primarily to run without user intervention

15 of 69

System View

  • the operating system is the program most intimately involved with the hardware
  • In this context, we can view an operating system as a resource allocator.
  • A computer system has many resources that may be required to solve a problem
    • CPU time, memory space, file-storage space, I/O devices, and so on.
  • Facing numerous and possibly conflicting requests for resources, the operating system must decide how to allocate them to specific programs and users so that it can operate the computer system efficiently and fairly.

16 of 69

  • OS control the various I/O devices and user programs
  • A control program manages the execution of user programs to prevent errors and improper use of the computer

17 of 69

Definition

  • Computers are present within toasters, cars, ships, spacecraft, homes, and businesses
  • They are the basis for game machines, music players, cable TV tuners, and industrial control systems
  • In the 1960s, Moore’s Law predicted that the number of transistors on an integrated circuit would double every eighteen months, and that prediction has held true
  • No completely adequate definition of an operating system

18 of 69

  • The fundamental goal of computer systems is to execute user programs and to make solving user problems easier.
  • Since bare hardware alone is not particularly easy to use, application programs are developed
  • These programs require certain common operations, such as those controlling the I/O devices.
  • The common functions of controlling and allocating resources are then brought together into one piece of software: theoperatingsystem.

19 of 69

Kernel

  • Some operating systems take up less than a megabyte of space and lack even a full-screen editor, whereas others require gigabytes of space and are based entirely on graphical windowing systems
  • A more common definition, and the one that we usually follow, is that the operating system is the one program running at all times on the computer—usually called the kernel.

20 of 69

  • Along with the kernel, there are two other types of programs: system programs ,which are associated with the operating system but are not necessarily part of the kernel, and application programs, which include all programs not associated with the operation of the system.

21 of 69

What constitutes an OS?

  • In 1998, the United States Department of Justice filed suit against Microsoft, in essence claiming that Microsoft included too much functionality in its operating systems and thus prevented application vendors from competing.
  • For example, a Web browser was an integral part of the operating systems.
  • As a result, Microsoft was found guilty of using its operating-system monopoly to limit competition.

22 of 69

  • Mobile operating systems often include not only a core kernel but also middleware—a set of software frameworks that provide additional services to application developers
  • For example, each of the two most prominent mobile operating systems—Apple’s iOS and Google’s Android—features acorekernelalongwithmiddlewarethatsupportsdatabases,multimedia,and graphics(to name a only few).

23 of 69

Operating System Structure

  • One of the most important aspects of operating systems is the ability to multiprogram
  • Single users frequently have multiple programs running. Multiprogramming increases CPU utilization by organizing jobs (code and data) so that the CPU always has one to execute

24 of 69

25 of 69

Time Sharing Systems

  • Multiprogrammed systems provide an environment in which the various system resources (for example, CPU, memory, and peripheral devices) are utilized effectively, but they do not provide for user interaction with the computer system
  • Time sharing (or multitasking) is a logical extension of multiprogramming.
  • In time-sharing systems, the CPU executes multiple jobs by switching among them, but the switches occur so frequently that the users can interact with each program while it is running.

26 of 69

  • Time sharing requires an interactive computer system, which provides direct communication between the user and the system.
  • The user gives instructions to the operating system or to a program directly, using a input device such as a keyboard, mouse, touch pad, or touch screen, and waits for immediate results on an output device. Accordingly, the response time should be short—typically less than one second.

27 of 69

Scheduling

  • A program loaded into memory and executing is called a process.
  • Time sharing and multiprogramming require that several jobs be kept simultaneously in memory
  • If several jobs are ready to be brought in to memory, and if there is not enough room for all of them, then the system must choose among them.
  • Making this decision involves job scheduling

28 of 69

  • .When the operating system selects a job from the job pool, it loads that job into memory for execution
  • Having several programs in memory at the same time requires some form of memory management
  • In addition, if several jobs are ready to run at the same time, the system must choose which job will run first. Making this decision is CPU scheduling

29 of 69

  • Finally, running multiple jobs concurrently requires that their ability to affect one another be limited in all phases of the operating system, including process scheduling, disk storage, and memory management.

30 of 69

Swapping and Virtual Memory

  • In a time-sharing system, the operating system must ensure reasonable response time.
  • This goal is sometimes accomplished through swapping, where by processes are swapped in and out of main memory to the disk
  • Amore common method for ensuring reasonable response time is virtual memory
  • Virtual Memory is a technique that allows the execution of a process that is not completely in memory

31 of 69

  • The main advantage of the virtual-memory scheme is that it enables users to run programs that are larger than actual physical memory.
  • Further, it abstracts main memory into a large, uniform array of storage, separating logical memory as viewed by the user from physical memory.
  • This arrangement frees programmers from concern over memory-storage limitations.

32 of 69

Other requirements of time sharing system

  • A time-sharing system must also provide a file system
  • The file system resides on a collection of disks; hence, disk management must be provided
  • In addition, a time-sharing system provides a mechanism for protecting resources from inappropriate use
  • To ensure orderly execution, the system must provide mechanisms for job synchronization and communication

33 of 69

  • It may ensure that jobs do not get stuck in a deadlock, for ever waiting for one another

34 of 69

Operating System Operations

  • 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 (or an exception) 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.

35 of 69

  • 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 to deal with the interrupt

36 of 69

  • 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 running.
  • With sharing, many processes could be adversely affected by a bug in one program
  • Without protection against these sorts of errors, either the computer must execute only one process at a time or all output must be suspect.

37 of 69

Dual mode and multi-mode operations

  • In order to ensure the proper execution of the operating system, we must be able to distinguish between the execution of operating-system code and user defined code
  • The approach taken by most computer systems is to provide hardware support that allows us to differentiate among various modes of execution.

38 of 69

39 of 69

  • At the very least, we need two separate 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).
  • With the mode bit, we can distinguish between a task that is executed on behalf of the operating system and one that is executed on behalf of the user.

40 of 69

  • When the computer system is executing on behalf of a user application, the system is in user mode. However, when a user application requests a service from the operating system
  • At system boot time, the hardware starts in kernel mode.
  • The operating system is then loaded and starts user applications in user mode

41 of 69

  • Whenever a trap or interrupt occurs, the hardware switches from user mode to kernel mode (that is, changes the state of the mode bit to 0).
  • Thus, whenever the operating system gains control of the computer, it is in kernel mode.
  • The system always switches to user mode (by setting the mode bit to 1) before passing control to a user program.

42 of 69

  • The dual mode of operation provides us with the means for protecting the operating system from errant users—and errant users from one another
  • Priviliged instructions: The hardware allows privileged instructions to be executed only in kernel mode
  • If an attempt is made to execute a privileged instruction in user mode, the hardware does not execute the instruction but rather treats it as illegal and traps it to theoperating system

43 of 69

  • The instruction to switch to kernel mode is an example of a privileged instruction.
  • Some other examples include I/O control, timer management, and interrupt management

44 of 69

  • The concept of modes can be extended beyond two modes
  • CPUs that support virtualization frequently have a separate mode to indicate when the virtual machine manager (VMM)—and the virtualization management software—is in control of the system
  • In this mode, the VMM has more privileges than user processes but fewer than the kernel
  • It needs that level of privilege so it can create and manage virtual machines, changing the CPU state to do so.

45 of 69

  • The Intel 64 family of CPUs supports four privilege levels
  • Accordingly, most contemporary operating systems—such as Microsoft Windows 7, as well as Unix and Linux—take advantage of this dual-mode feature and provide greater protection for the operating system.

46 of 69

Timer

  • We must ensure that the operating system maintains control over the CPU.
  • A timer can be set to interrupt the computer after a specified period.
  • A variable timer is generally implemented by a fixed-rate clock and a counter.
  • The operating system sets the counter.
  • Every time the clock ticks, the counter is decremented.
  • When the counter reaches 0, an interrupt occurs.
  • For instance, a 10-bit counter with a 1-millisecond clock allows interrupts at intervals from 1 millisecond to 1,024 milliseconds, in steps of 1 millisecond.

47 of 69

  • If the timer interrupts, control transfers automatically to the operating system, which may treat the interrupt as a fatal error or may give the program more time.
  • Clearly, instructions that modify the content of the timer are privileged.

48 of 69

Process Management

  • Process is a program in execution
  • A process needs certain resources—including CPU time, memory, files, and I/O devices—to accomplish its task
  • These resources are either given to the process when it is created or allocated to it while it is running
  • Various initialization data (input) may be passed along
  • A program is a passive entity, like the contents of a file stored on disk
  • A process is an active entity.

49 of 69

  • A single-threaded process has one program counter specifying the next instruction to execute
  • The CPU executes one instruction of the process after another, until the process completes
  • A multithreaded process has multiple program counters, each pointing to the next instruction to execute for a given thread
  • A system consists of a collection of processes, some of which are operating-system processes (those that execute
  • system code) and the rest of which are user processes (those that execute user code).

50 of 69

Process management Tasks

  • The operating system is responsible for the following activities in connection with process management:
    • Scheduling processes and threads on the CPUs
    • Creating and deleting both user and system processes
    • Suspending and resuming processes
    • Providing mechanisms for process synchronization
    • Providing mechanisms for process communication

51 of 69

Memory management

  • Main memory is a large array of bytes, ranging in size from hundreds of thousands to billions
  • The central processor reads instructions from main memory during the instruction-fetch cycle and both reads and writes data from main memory during the data-fetch cycle
  • The main memory is generally the only large storage device that the CPU is able to address and access directly

52 of 69

  • For a program to be executed, it must be mapped to absolute addresses and loaded into memory
  • General-purpose computers must keep several programs in memory, creating a need for memory management

53 of 69

Memory management tasks

  • The operating system is responsible for the following activities in connection with memory management:
    • Keeping track of which parts of memory are currently being used and who is using them
    • Deciding which processes (or parts of processes) and data to move into and out of memory
    • Allocating and deallocating memory space as needed

54 of 69

Storage management

  • The operating system provides a uniform, logical view of information storage.
  • Computers can store information on several different types of physical media
  • Each medium is controlled by a device, such as a disk drive or tape drive
  • Properties of medium: access speed, capacity, data-transfer rate, and access method (sequential or random).

55 of 69

  • The operating system implements the abstract concept of a file by managing mass-storage media, such as tapes and disks, and the devices that control them
  • When multiple users have access to files, it may be desirable to control which user may access a file and how that user may access it

56 of 69

File management activities

  • Creating and deleting files
  • Creating and deleting directories to organize files
  • Supporting primitives for manipulating files and directories
  • Mapping files onto secondary storage
  • Backing up files on stable (nonvolatile) storage media

57 of 69

Mass storage management

  • The operating system is responsible for the following activities in connection with disk management:
    • Free-space management
    • Storage allocation
    • Disk scheduling

58 of 69

  • Why secondary storage despite being slow?
    • Backups of disk data, storage of seldom-used data, and long-term archival storage
  • Magnetic tape drives and their tapes and CD and DVD drives and platters are typical tertiary storage devices.
  • The media (tapes and optical platters) vary between WORM (write-once, read-many-times) and RW (read–write) formats.

59 of 69

  • Some operating systems take on managing tertiary storage, while others leave tertiary-storage management to application programs.
  • Mounting and unmounting media in devices,
  • allocating and freeing the devices for exclusive use by processes,
  • Migrating data from secondary to tertiary storage.

60 of 69

Caching

  • Caching concept
  • Caches are implemented typically in hardware
  • Most systems have an instruction cache to hold the instructions expected to be executed next
  • Most systems have one or more high-speed data caches in the memory hierarchy
  • Careful selection of the cache size and of a replacement policy can result in greatly increased performance

61 of 69

  • Main memory can be viewed as a fast cache for secondary storage
  • Data transfer from cache to CPU and registers is usually a hardware function, with no operating-system intervention.
  • In contrast, transfer of data from disk to memory is usually controlled by the operating system.
  • Note that the same data may appear in different levels of the storage system

62 of 69

63 of 69

Cache consistency

  • In a multitasking environment, extreme care must be taken to ensure that processes obtain the most recently updated value.
  • The situation becomes more complicated in a multiprocessor environment with local cache
  • This situation is called cache coherency, and it is usually a hardware issue
  • In a distributed environment, the situation becomes even more complex
  • Same file can be kept on different computers

64 of 69

I/O System

  • Hide the peculiarities of specific hardware devices from the user.
  • The I/O subsystem consists of several components:
    • A memory-management component that includes buffering, caching, and spooling
    • A general device-driver interface
    • Drivers for specific hardware devices
  • Only the device driver knows the peculiarities of the specific device to which it is assigned.

65 of 69

Protection

  • Protection, then, is any mechanism for controlling the access of processes or users to the resources defined by a computer system
  • Memory-addressing hardware ensures that a process can execute only within its own address space
  • The timer ensures that no process can gain control of the CPU without eventually relinquishing control
  • Device-control registers are not accessible to users, so the integrity of the various peripheral devices is protected

66 of 69

Security

  • It is the job of security to defend a system from external and internal attacks.
  • Include viruses and worms, denial-of service attacks, identity theft, and theft of service
  • Most operating systems maintain a list of user names and associated user identifiers (user IDs).
  • Group functionality can be implemented as a system-wide list of group names and group identifiers

67 of 69

Data Structures in Operating System

  • Linked List
    • Singly linked list
    • Doubly linked list
    • Circularly linked list
  • Stack
  • Queues
  • Trees
    • Binary tree
    • Balanced binary tree
  • Hash function
    • Collision

68 of 69

Computing Environments

  • Traditional Computing
  • Client Server Computing
  • Mobile Computing
    • Augmented Reality
  • Distributed System
  • P2P computing
  • Cloud Computing
    • EC2
    • Public, private, hybrid cloud
    • SaaS, IaaS, PaaS
  • Embedded Computing

69 of 69

Open Source Operating System

  • Reverse Engineering
  • GNU General Public License (GPL)
  • Linux
  • BSD UNIX
  • Solaris