Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Operating System Module 1 to 6 Reviewer, Lecture notes of Operating Systems

Review all module that being discuss during this semester

Typology: Lecture notes

2020/2021
On special offer
30 Points
Discount

Limited-time offer


Uploaded on 07/19/2021

christelyn-obliopas
christelyn-obliopas 🇵🇭

5 documents

1 / 65

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
Applied Operating System
Educational Resources Information
Module Number
Sub Topic Number
Supplementary Level
1
1
1
SUBTOPIC: OPERATING SYSTEM OVERVIEW
What is an Operating System?
An Operating System (OS) is a program or system software that acts as an interface between the
user and the computer hardware and controls the execution of all kinds of programs.
Goals of an Operating System?
Execute user programs and make solving user problems easier.
Make the computer system convenient to use.
Use the computer hardware in an efficient manner.
Components of a Computer System
Computer hardware CPU, memory and I/O devices, provides the basic computing
resources.
Application programs are used to solve the computing problems of the users such as
word processors, games and business programs.
Users who utilize a computer or network service trying to solve different problems.
Operating System controls and coordinates the use of the hardware among the various
application programs for the various users.
What is a Kernel?
Kernel is the central part of an OS which manages system resources and is always resident in
memory. It also acts like a bridge between application and hardware of the computer. It is also
the first program that loads after the bootloader.
Bootloader is a program that loads and starts the boot time tasks and processes of an OS. It
also places the OS of a computer into memory.
Common Services Offered By Almost All Operating Systems:
User Interface
Program Execution
File system manipulation
Input / Output Operations
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
Discount

On special offer

Partial preview of the text

Download Operating System Module 1 to 6 Reviewer and more Lecture notes Operating Systems in PDF only on Docsity!

Applied Operating System

Educational Resources Information

Module Number Sub Topic Number Supplementary Level 1 1 1

SUBTOPIC: OPERATING SYSTEM OVERVIEW

What is an Operating System? An Operating System (OS) is a program or system software that acts as an interface between the user and the computer hardware and controls the execution of all kinds of programs.

Goals of an Operating System?

 Execute user programs and make solving user problems easier.  Make the computer system convenient to use.  Use the computer hardware in an efficient manner.

Components of a Computer SystemComputer hardware – CPU, memory and I/O devices, provides the basic computing resources.  Application programs – are used to solve the computing problems of the users such as word processors, games and business programs.  Users – who utilize a computer or network service trying to solve different problems.  Operating System – controls and coordinates the use of the hardware among the various application programs for the various users.

What is a Kernel? Kernel is the central part of an OS which manages system resources and is always resident in memory. It also acts like a bridge between application and hardware of the computer. It is also the first program that loads after the bootloader.

Bootloader is a program that loads and starts the boot time tasks and processes of an OS. It also places the OS of a computer into memory.

Common Services Offered By Almost All Operating Systems:  User Interface  Program Execution  File system manipulation  Input / Output Operations

 Communication  Resource Allocation  Error Detection  Accounting  Security and protection

Types of Operating System

 Batch operating system  Time-sharing operating systems  Distributed operating system  Network operating system  Real-time operating system  Handheld operating system

Batch Operating System (BOS) The user of a BOS never directly interacts with the computer. Every user prepares his or her job on an offline device like a punch card and submit it to the computer operator.  Examples: Payroll System, Bank Statements etc.

Time-sharing Operating System Time-sharing or multitasking is logical extension in which CPU switches jobs so frequently that users can interact with each job while it is running, creating interactive computing.

  • Examples: Unix, Linux, Multics and Windows

Distributed Operating System Distributed systems use multiple central processors to serve multiple real-time applications and multiple users. Data processing jobs are distributed among the processors accordingly.

  • Examples: Telecom Network, WWW, Cloud Computing, etc.

Network Operating System (NOS) A NOS runs on a server and provides the server the capability to manage data, users, groups, security, applications, and other networking functions.  Examples: Microsoft Windows Server 2003, Microsoft Windows Server 2008, UNIX, Linux, Mac OS X Server, Novell NetWare, and BSD/OS (Berkeley Software Design)

Real-time Operating System (RTOS) RTOS is an operating system intended to serve real-time systems/applications that process data as it comes in, mostly without buffer delay.

  • Examples: LynxOS, OSE, QNX, RTLinux, VxWorks, Windows CE

Handheld Operating System It is also known as Mobile OS which is built exclusively for a mobile device, such as a smartphone, personal digital assistant (PDA), tablet, wearable devices or other embedded mobile OS.

  • Examples: Android, Symbian, iOS, BlackBerry OS and Windows Mobile.

 It alerts the processor temporarily to a high priority process requiring interruption of the current working process and then return to its previous task.

Types of Interrupts:  Hardware interrupt  Software interrupt

Hardware interrupt is a signal created and sent to the CPU that is caused by some action taken by a hardware device. Example: When a key is pressed or when the mouse is moved.

Software Interrupt arises due to illegal and erroneous use of an instruction or data. It often occurs when an application software terminates or when it requests the operating system for some service. Example: stack overflow, division by zero, invalid opcode, etc. These are also called traps.

Interrupt Handling The operating system preserves the state of the CPU by storing registers and the program counter Determines which type of interrupt has occurred:

 Polling – operating system sends signal to each devices asking if they have a request  Vectored interrupt system – requesting device sends interrupt to the operating system. Separate segments of code determine what action should be taken for each type of interrupt.

Operating System Operations  Dual-mode operation allows OS to protect itself and other system components  User mode and kernel mode  Mode bit provided by hardware  Provides ability to distinguish when system is running user code(1) or kernel code(0)  Some instructions designated as privileged, only executable in kernel mode  System call changes mode to kernel, return from call resets it to user A system call is a way for programs to interact with the OS. A computer program makes a system call when it makes a request to the OS‘s kernel.

Single-Processor System There is one main CPU capable of executing a general-purpose instruction set, including instructions from user processes.

Multiprocessor System Also known as parallel-system or multicore. First appeared in servers and now in smartphones and tablet computers.

Computer System Architecture

 Most systems use a single general-purpose processor (PDAs through mainframes)  Most systems have special-purpose processors as well  Multiprocessors systems growing in use and importance  Also known as parallel systems or tightly-coupled systems

Advantages :

  1. Increased throughput. Increasing the number of processor, expect to get more work done in less time.
  2. Economy of scale. It can cost less than equivalent multiple single-processor systems because they can share peripherals, mass storage and power supplies.
  3. Increased reliability. Functions can be distributed properly among several processors. If one processor fails, the other processor can pick-up the task. Two types of Multiprocessing:  Asymmetric Multiprocessing  Symmetric Multiprocessing
  4. Asymmetric multiprocessing. Each processor is assigned a specific task. A boss processor controls the system and the other processors either look to the boss for instructions or have predefined tasks. Boss-worker relationship.
  5. Symmetric multiprocessing(SMP). The most commonly used. In which each processor performs all tasks within the operating system. All processors are peers and no boss- worker relationship. The difference between symmetric and asymmetric may result from either hardware or software.

A recent trend in CPU design is to include multiple computing cores on a single chip. Such multiprocessor systems are termed multicore. They can be more efficient than multiple chips with single core. A dual-core design with two cores on the same chip. Each core has its own register set as well as its own local cache.

Clustered System  Like multiprocessor systems, but multiple systems working together  Usually sharing storage via a storage-area network (SAN)  Provides a high-availability service which survives failures  Asymmetric clustering has one machine in hot-standby mode  Symmetric clustering has multiple nodes running applications, monitoring each other  Some clusters are for high-performance computing (HPC).

Computing Environment

Office computing environment o PCs connected to a network, terminals attached to mainframe or minicomputers providing batch and timesharing o Now portals allowing networked and remote systems access to same resources

Home computing environment o Used to be single system, then modems o Now firewalled, networked

Mobile computing o Refers to computing on handheld smartphones and tablet computers.

Platform as a service(PaaS) – software stack ready for application use via the Internet  Infrastructure as a service(IaaS) – servers or storage available over the Internet

Open-Source Operating System

Open Source operating systems are released under a license where the copyright holder allows others to study, change as well as distribute the software to other people.  Counter to the copy protection and Digital Rights Management (DRM) movement  Started by Free Software Foundation (FSF), which has “copyleft” GNU Public License (GPL)  Examples: GNU( GNU’s N ot U nix)/Linux, BSD UNIX (including core of Mac OS X), and Sun Solaris

Applied Operating System

Educational Resources Information

Module Number Sub Topic Number Supplementary Level 2 1 1

SUBTOPIC 1: PROCESS MANAGEMENT

PROCESS CONCEPT

  • A process is a program in execution. A program by itself is not a process.
  • A program is a passive entity , such as the contents of a file stored on disk while a process is an active entity.
  • A computer system consists of a collection of processes:
    • Operating system processes execute system code , and
    • User processes execute user code.
  • Although several processes may be associated with the same program, they are nevertheless considered separate execution sequences.
  • All processes can potentially execute concurrently with the CPU (or CPUs) multiplexing among them (time sharing).
  • A process is actually a cycle of CPU execution (CPU burst) and I/O wait (I/O burst). Processes alternate back and forth between these two states.
  • Process execution begins with a CPU burst that is followed by an I/O burst , which is followed by another CPU burst, then another I/O burst, and so on. Eventually, the last CPU burst will end with a system request to terminate execution.

Example :

PROCESS STATE

As a process executes, it changes state. The current activity of a process party defines its state. Each sequential process may be in one of following states:

  1. New. The process is being created.
  2. Running. The CPU is executing its instructions.
  3. Waiting. The process is waiting for some event to occur (such as an I/O completion).
  4. Ready. The process is waiting for the OS to assign a processor to it.
  5. Terminated. The process has finished execution.

PROCESS STATE DIAGRAM

PROCESS CONTROL BLOCK

Each process is represented in the operating system by a process control block (PCB) – also called a task control block. A PCB is a data block or record containing many pieces of the information associated with a specific process including:

  1. Process state. The state may be new, ready, running, waiting, or halted.
  2. Program Counter. The program counter indicates the address of the next instruction to be executed for this process.
  3. CPU Registers. These include accumulators, index registers, stack pointers, and general-purpose registers, plus any condition-code information. Along with the program counter, this information must be saved when an interrupt occurs, to allow the process to be continued correctly afterward.

ready running

waiting

interrupt

scheduler dispatch I/O or event

wait

I/O or event

completion

new admitted exit terminated

  1. CPU Scheduling Information. This information includes a process priority, pointers to scheduling queues, and any other scheduling parameters.
  2. Memory Management Information. This information includes limit registers or page tables.
  3. Accounting Information. This information includes the amount of CPU and real time used, time limits, account numbers, job or process numbers, and so on.
  4. I/O Status Information. This information includes outstanding I/O requests, I/O devices (such as disks) allocated to this process, a list of open files, and so on.
  • The PCB simply serves as the repository for any information that may vary from process to process.

PROCESS CONCEPT

Example of the CPU being switched from one process to another. This is also known as Context Switch Diagram

pointer processstate process number program counter

registers

memory limits list of open files

. . .

save state into PCB 0

reload state into PCB 1

. . .

save state into PCB 1

reload state into PCB 0

. . .

process P 0 operating system process P 1

executing

executing

executing

interrupt or system call

interrupt or system call

idle

idle

idle

  1. The results of its execution cannot be predicted in advance, since it depends on relative execution sequence.
  2. The result of its execution is nondeterministic since it will not always be the same for the same input. Concurrent execution of cooperating process requires mechanisms that allow processes to communicate with one another and to synchronize their actions.

SCHEDULING CONCEPTS

  • The objective of multiprogramming is to have some process running at all times, to maximize CPU utilization.
  • Multiprogramming also increases throughput , which is the amount of work the system accomplishes in a given time interval (for example, 17 processes per minute).

Example:

Given two processes, P 0 and P 1.

If the system runs the two processes sequentially, then CPU utilization is only 50%.

  • The idea of multiprogramming is if one process is in the waiting state, then another process which is in the ready state goes to the running state.

Example: Applying multiprogramming to the two processes, P 0 and P 1

Then CPU utilization increases to 100%.

process P 0 start (^) idle; input

idle; input

idle; input

stop

process P 1 start (^) idle; input

idle; input

idle; input

stop

process P 0 start (^) idle; input

idle; input

idle; input

stop

process P 1 start (^) idle; input

idle; input

idle; input

stop

  • As processes enter the system, they are put into a job queue. This queue consists of all processes in the system.
  • The processes that are residing in main memory and are ready and waiting to execute are kept on another queue which is the ready queue.
  • A process migrates between the various scheduling queues throughout its lifetime. The OS must select processes from these queues in some fashion.
  • The selection process is the responsibility of the appropriate scheduler.

TYPES OF SCHEDULER

  • Long-term scheduler (or J ob scheduler ) selects processes from the secondary storage and loads them into memory for execution.
  • The long-term scheduler executes much less frequently.
  • There may be minutes between the creation of new processes in the system.
  • The long-term scheduler controls the degree of multiprogramming – the number of processes in memory.
  • Because of the longer interval between executions, the long-term scheduler can afford to take more time to select a process for execution.
  • Short-term scheduler (or CPU scheduler ) selects process from among the processes that are ready to execute, and allocates the CPU to one of them.
  • The short-term scheduler must select a new process for the CPU frequently.
  • A process may execute for only a few milliseconds before waiting for an I/O request.
  • Because of the brief time between executions, the short-term scheduler must be very fast.
  • Medium-term scheduler removes (swaps out) certain processes from memory to lessen the degree of multiprogramming (particularly when thrashing occurs).
  • At some later time, the process can be reintroduced into memory and its execution can be continued where it left off.
  • This scheme is called swapping.

SCHEDULING CONCEPTS

  • Switching the CPU to another process requires some time to save the state of the old process and loading the saved state for the new process. This task is known as context switch.
  • Context-switch time is pure overhead, because the system does no useful work while switching and should therefore be minimized.
  • Whenever the CPU becomes idle, the OS (particularly the CPU scheduler) must select one of the processes in the ready queue for execution.

CPU SCHEDULER

CPU scheduling decisions may take place under the following four circumstances:

  1. When a process switches from the running state to the waiting state (for example, I/O request, invocation of wait for the termination of one of the child processes).

periods spent waiting to get into memory, waiting in the ready queue, executing in the CPU, and doing I/O.

  1. Waiting Time is the time a job waits for resource allocation when several jobs are competing in multiprogramming system. Waiting time is the total amount of time a process spends waiting in the ready queue.
  2. Response Time is the time from the submission of a request until the system makes the first response. It is the amount of time it takes to start responding but not the time that it takes to output that response.

A good CPU scheduling algorithm maximizes CPU utilization and throughput and minimizes turnaround time, waiting time and response time.

  • In most cases, the average measure is optimized. However, in some cases, it is desired to optimize the minimum or maximum values, rather than the average.
  • For example , to guarantee that all users get good service, it may be better to minimize the maximum response time.
  • For interactive systems (time-sharing systems), some analysts suggests that minimizing the variance in the response time is more important than averaging response time.
  • A system with a reasonable and predictable response may be considered more desirable than a system that is faster on the average, but is highly variable.

Non-preemptive:

  • First-Come First-Served(FCFS)
  • Shortest Job First (SJF)
  • Priority Scheduling (Non-preemptive)

Preemptive:

  • Shortest Remaining Time First (SRTF)
  • Priority Scheduling (Preemptive)
  • Round-robin (RR)

REFERENCES

  • Siberschatz, A. (2018). Operating System Concepts, Wiley.
  • Tomsho, G. (2019). Guide to Operating Systems, Cengage Learning.

Applied Operating System

Educational Resources Information

Module Number Sub Topic Number Supplementary Level 2 2 1

SUBTOPIC 2: CPU SCHEDULING TECHNIQUES – NON PREEMPTIVE

FIRST-COME FIRST-SERVED (FCFS)

  • FCFS is the simplest CPU-scheduling algorithm.
  • The process that requests the CPU first gets the CPU first.
  • The FCFS algorithm is non-preemptive.

Example 1:

  • Consider the following set of processes that arrive at time 0 , with the length of the CPU burst given in milliseconds (ms).
  • Illustrate the Gantt chart and compute for the average waiting time and average turnaround time

Given:

Process

Arrival Time

Burst time

Waiting Time

Turnaround Time P1 0 5 0 - 0 = 0 5 - 0 = 5 P2 0 3 5 - 0 =^^5^8 - 0 =^^8 P3 0 8 8 - 0 =^^8^16 - 0 =^16 P4 0 6 16 - 0 = 16 22 - 0 = 22

Average

7.25 ms

12.75 ms

Gantt Chart:

Example 1:

Process Arrival Time

Burst time

Waiting Time

Turnaround Time P1 0 5 3 - 0 = 3 8 - 0 = 8 P2 0 3 0 - 0 = 0 3 - 0 = P3 0 8 14 - 0 = 14 22 - 0 = 22 P4 0 6 8 - 0 = 8 14 - 0 =

Average

6.25 ms

11.75 ms

Gantt Chart:

Example 2 :

Process

Arrival Time

Burst time

Waiting Time

Turnaround Time P1 (^0 5 0) - 0 = 0 5 - 0 = 5 P2 1 3 5 - 1 = 4 8 - 1 = 7 P3 2 8 14 - 2 = 12 22 - 2 = 20 P4 3 6 8 - 3 = 5 14 - 3 = 11

Average

5.25 ms

10.75 ms

Gantt Chart:

PRIORITY SCHEDULING (NP)

  • Priority scheduling (non-preemptive) algorithm is one of the most common scheduling algorithms in batch systems.
  • Each process is assigned a priority.
  • Process with highest priority is to be executed first and so on.
  • Processes with same priority are executed on FCFS basis.
  • Priority can be decided based on memory requirements, time requirements or any other resource requirement.

Example 1:

Consider the lowest priority value gets the highest priority. In this case, process with priority value (1) is the highest priority.

Process

Arrival Time

Burst time

Priority

Waiting Time

Turnaround Time P1 0 5 1 0 - 0 = 0 5 - 0 = 5 P2 (^0 3 2 13) - 0 = 13 16 - 0 = 16 P3 0 8 1 5 - 0 = 5 13 - 0 = 13 P4 0 6 3 16 - 0 = 16 22 - 0 = 22

Average 34/ 8.5 ms

14 ms

Gantt Chart:

REFERENCES

  • Siberschatz, A. (2018). Operating System Concepts, Wiley.
  • Tomsho, G. (2019). Guide to Operating Systems, Cengage Learning.