11
© Ashek Mahmud Khan Chapter: 01 (Introduction) Ashek Mahmud Khan Q.1: Define Operating system. What are the goals of operating system? Ans: An operating system, or "OS," is software that communicates with the hardware and allows other programs to run. Or, An operating system (OS) is software that manages computer hardware and software. Common desktop operating systems include Windows, Mac OS X, and Linux. Operating system goals (i) Execute user programs and make solving user problems easier. (ii) Make the computer system convenient to use. Q.2: Define the essential properties of the following types of operating systems (i) Batch (ii) Time-sharing (iii) Real time (iv) Handheld (v) Interactive (vi) Network (vii) Parallel (viii) Distributed (ix) Clustered (i) Batch: Batch operating system is one where programs and data are collected together in a batch before processing starts. A job is predefined sequence of commands, programs and data that are combined in to a single unit called job. Memory management in batch system is very simple. Memory is usually divided into two areas: Operating system and user program area. (ii) Time-sharing: This systems uses CPU scheduling and multiprogramming to provide economical interactive use of a system. The CPU switches rapidly from one user to another. Time-sharing operating systems are even more complex than are multi-programmed operating systems. (iii) Real time: Real time systems are usually dedicated, embedded systems. They typically read from and react to sensor data. The system must guarantee response to events within fixed periods of time to ensure correct performance. (iv) Handheld: A small computer system that performs simple tasks such as calendars, email, and web browsing. Handheld systems differ from traditional desktop systems with smaller memory and display screens and slower processors. (v) Interactive: User is on line with computer system and interacts with it via an interface. It is typically composed of many short transactions where the result of the next transaction may be unpredictable. Response time needs to b e short since the user submits and waits for the result. (vi) Network: Provides operating system features across a network such as file sharing.

Operating system

Embed Size (px)

Citation preview

Page 1: Operating system

© Ashek Mahmud Khan

Chapter: 01 (Introduction) Ashek Mahmud Khan

Q.1: Define Operating system. What are the goals of operating system?

Ans: An operating system, or "OS," is software that communicates with the hardware and allows other

programs to run. Or, An operating system (OS) is software that manages computer hardware and

software. Common desktop operating systems include Windows, Mac OS X, and Linux.

Operating system goals

(i) Execute user programs and make solving user problems easier.

(ii) Make the computer system convenient to use.

Q.2: Define the essential properties of the following types of operating systems

(i) Batch (ii) Time-sharing (iii) Real time (iv) Handheld (v) Interactive (vi) Network (vii) Parallel

(viii) Distributed (ix) Clustered

(i) Batch: Batch operating system is one where programs and data are collected together in a batch

before processing starts. A job is predefined sequence of commands, programs and data that are

combined in to a single unit called job. Memory management in batch system is very simple. Memory is

usually divided into two areas: Operating system and user program area.

(ii) Time-sharing: This systems uses CPU scheduling and multiprogramming to provide economical

interactive use of a system. The CPU switches rapidly from one user to another. Time-sharing operating

systems are even more complex than are multi-programmed operating systems.

(iii) Real time: Real time systems are usually dedicated, embedded systems. They typically read from

and react to sensor data. The system must guarantee response to events within fixed periods of time to

ensure correct performance.

(iv) Handheld: A small computer system that performs simple tasks such as calendars, email, and web

browsing. Handheld systems differ from traditional desktop systems with smaller memory and display

screens and slower processors.

(v) Interactive: User is on line with computer system and interacts with it via an interface. It is

typically composed of many short transactions where the result of the next transaction may be

unpredictable. Response time needs to b e short since the user submits and waits for the result.

(vi) Network: Provides operating system features across a network such as file sharing.

Page 2: Operating system

© Ashek Mahmud Khan

(vii) Parallel: Used in systems where there are multiple CPU‟s each running the same copy of the

operating system. Communication takes place across the system bus.

(viii) Distributed: This system distributes computation among several physical processors. The

processors do not share memory or a clock. Instead, each processor has its own local memory. They

communicate with each other through various communication lines, such as a high‐speed bus or local

area network.

(ix) Clustered: A clustered system combines multiple computers into a single system to perform

computational task distributed across the cluster.

Computer System Structure: Computer system can be divided into four components- Hardware,

Operating system, Application programs, Users.

Hardware: provides basic computing resources. CPU, memory, I/O devices.

Operating system: Controls and coordinates use of hardware among various applications and users.

Application programs: define the ways in which the system resources are used to solve the computing

problems of the users. Word processors, compilers, web browsers, database systems, video games

Users: People, machines, other computers.

Fig: Abstract view of the components of a computer system

Interrupt Timeline:

Fig: Interrupt time line for a single process doing output

Page 3: Operating system

© Ashek Mahmud Khan

Storage Hierarchy: Storage systems organized in hierarchy.

(1) Speed

(2) Cost

(3) Volatility

Caching – copying information into faster storage system; main memory can be viewed as a last cache

for secondary storage.

Storage-Device Hierarchy:

The difference between symmetric and asymmetric multiprocessing:

Symmetric Multiprocessing Asymmetric Multiprocessing

(i) Symmetric multiprocessing (SMP) technology

is used to get higher levels of performance.

(i) In asymmetric multiprocessing (ASMP), the

operating system typically sets aside one or more

processors for its exclusive use.

(ii) SMP systems provide better load-balancing

and fault tolerance.

(ii) SMP systems are inherently more complex

than ASMP systems.

(iii) In symmetric multiprocessing, any processor

can run any type of thread.

(iii) The remainder of the processors run user

applications.

Difference between a process and a program

- A program is a set of instructions that are to perform a designated task, where as the process is an

operation which takes the given instructions and perform the manipulations as per the code, called

„execution of instructions‟. A process is entirely dependent of a „program‟.

- A process is a module that executes modules concurrently. They are separate loadable modules.

Whereas the program perform the tasks directly relating to an operation of a user like word processing,

executing presentation software etc.

Chapter: 02 (System Structures)

Q.3: What are the five major activities of an operating system in regard to process management?

a. The creation and deletion of both user and system processes

Page 4: Operating system

© Ashek Mahmud Khan

b. The suspension and resumption of processes

c. The provision of mechanisms for process communication

d. Free space management.

e. Storage allocation.

f. Disk Scheduling.

Q.4: What are the three major activities of an operating system in regard to memory

management?

a. Keep track of which parts of memory are currently being used and by whom.

b. Decide which processes are to be loaded into memory when memory space becomes available.

c. Allocate and deal locate memory space as needed.

Q.5: What are the three major activities of an operating system in regard to secondary storage

management?

a. Free-space management.

b. Storage allocation.

c. Disk scheduling.

Q.6: What is the purpose of system calls?

System calls allow user-level processes to request services of the operating system.

Types of System Calls:

(a) Process control (b) File management (c) Device management (d) Information maintenance (e)

Communications

Q.7: What is the purpose of system programs?

System programs can be thought of as bundles of useful system calls. They provide basic functionality

to users so that users do not need to write their own programs to solve common problems.

API – System Call – OS Relationship:

Page 5: Operating system

© Ashek Mahmud Khan

MS-DOS Layer Structure:

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.

Layered Operating System:

Q.8: What are the main advantages of the microkernel approach to system design?

Answer: Benefits typically include the following (a) adding a new service does not require modifying

the kernel, (b) it is more secure as more operations are done in user mode than in kernel mode, and (c) a

simpler kernel design and functionality typically results in a more reliable operating system.

Microkernel System Structure:

Moves as much from the kernel into “user” space.

Communication takes place between user modules using message passing.

Benefits:

-Easier to extend a micro kernel

-Easier to port the operating system to new architectures

-More reliable (less code is running in kernel mode)

-More secure

Page 6: Operating system

© Ashek Mahmud Khan

Operating System Generation: Operating systems are designed to run on any of a class of machines;

the system must be configured for each specific computer site

SYSGEN program obtains information concerning the specific configuration of the hardware system

Booting – starting a computer by loading the kernel

Bootstrap program – Code stored in ROM that is able to locate the kernel, load it into memory, and start

its execution

Chapter: 03 (Process Concept)

An operating system executes a variety of programs:

Batch system – jobs, Time-shared systems – user programs or tasks.

Process: Process is a program in execution; process execution must progress in sequential fashion. A

process includes: program counter, stack, data section.

Process in Memory:

Process State: Process state is defined as the current activity of the process. Process state contains five

states. Each process is in one of the states. The states are listed below- (i) New (ii) Ready (iii) Running

(iv) Waiting (v) Terminated (exist).

(i) New: The process is being created.

(ii) Ready: The process is waiting to be assigned to a process.

(iii) Running: Instructions are being executed.

(iv) Waiting: The process is waiting for some event to occur.

(v) Terminated: The process has finished execution.

Q.2013 (1-c): Describe the process state diagram. Diagram of Process State diagram:

Fig: Process State Diagram

Page 7: Operating system

© Ashek Mahmud Khan

Q.2013 (1-d): Describe process control Block (PBC) of a process.

Process Control Block (PCB): Each Process is represented is the operating system by a process control

block. Information associated with each process-

-Process state

-Program counter

-CPU registers

-CPU scheduling information

-Memory-management information

-Accounting information

-I/O status information

Fig: Process control Block (PBC)

Process State: Process state may be new, ready, running, waiting and so on.

Program Counter: It indicates the address of the next instruction to be executed for this process.

CPU register: It indicates general purpose register, stack pointers, index registers and accumulators

etc.

Memory Management Information: This information may include the value of base and limit

register.

Accounting Information: This information includes the amount of CPU and real time used, time limits,

job or process numbers, account numbers etc.

CPU Switch from Process to Process:

Page 8: Operating system

© Ashek Mahmud Khan

Q.2013 (2-a): Distinguish among job queue, ready queue and device queues.

Process Scheduling Queues:Job queue – set of all processes in the system

Ready queue – set of all processes residing in main memory, ready and waiting to execute

Device queues – set of processes waiting for an I/O device

Representation of Process Scheduling:

Schedulers: Scheduler are three types:

(i) Long term scheduler

(ii) Short term scheduler

(iii) Medium term scheduler

Long term scheduler: It is also called job scheduler. Long term scheduler determines which programs

are admitted to the system for processing.

Short term scheduler: It is also called CPU scheduler. Short term scheduler selects which process should

be executed next and allocates CPU.

The difference between Long term scheduler and Short term scheduler:

Long term scheduler Short term scheduler

(i) Long-term scheduler is called job scheduler. (i) Long-term scheduler is called CPU scheduler.

(ii) Long-term scheduler is invoked very

infrequently (seconds, minutes) (may be slow)

(ii) Short-term scheduler is invoked very

frequently (milliseconds) (must be fast)

(iii) The long-term scheduler executes much less

frequently; minutes may separate the creation of

one new process and the next.

(iii) The short-term scheduler is designed to

frequently select a new process for the CPU, at

least once every 100 milliseconds.

(iv) The long-term scheduler controls the degree of

multiprogramming

(iv)

Page 9: Operating system

© Ashek Mahmud Khan

Process Creation: Parent process create children processes, which, in turn create other processes,

forming a tree of processes.

Resource sharing:

(i) Parent and children share all resources

(ii) Children share subset of parent‟s resources

(iii) Parent and child share no resources

Execution:

(i) Parent and children execute concurrently

(ii) Parent waits until children terminate

Fig: Process Creation using frok() system call

Process Termination:

Process executes last statement and asks the operating system to delete it (exit).

Output data from child to parent (via wait)

Process‟ resources are deal located by operating system

A parent may terminate the execution of one of its children for a variety of reasons, such as these:

(i) The child has exceeded its usage of some of the resources that it has been allocated. (To determine

whether this has occurred, the parent must have a mechanism to inspect the state of its children).

(ii) The task assigned to the child is no longer required.

(iii) The parent is exiting, and the operating system does not allow a child to continue if its parent

terminates.

Cooperating Processes:

Independent process cannot affect or be affected by the execution of another process.

Cooperating process can affect or be affected by the execution of another process.

Advantages of process cooperation:

(i) Information sharing

(ii) Computation speed-up

(iii) Modularity

(iv) Convenience

Page 10: Operating system

© Ashek Mahmud Khan

Producer-Consumer Problem:

unbounded-buffer places no practical limit on the size of the buffer

bounded-buffer assumes that there is a fixed buffer size

Bounded-Buffer – Shared-Memory Solution:

Shared data

#define BUFFER_SIZE 10

Typedef struct {

. . .

}

item;item buffer[BUFFER_SIZE];

int in = 0;

int out = 0;

Solution is correct, but can only use BUFFER_SIZE-1 elements

Bounded-Buffer – Insert() Method:

while (true) {

/* Produce an item */

while (((in = (in + 1) % BUFFER SIZE count) == out)

; /* do nothing -- no free buffers */

buffer[in] = item;

in = (in + 1) % BUFFER SIZE;

{

Bounded Buffer – Remove() Method:

while (true) {

while (in == out)

; // do nothing -- nothing to consume

// remove an item from the buffer

item = buffer[out];

out = (out + 1) % BUFFER SIZE;

return item;

{

Page 11: Operating system

© Ashek Mahmud Khan

Synchronization:

Message passing may be either blocking or non-blocking

Blocking is considered synchronous

Blocking send has the sender block until the message is received

Blocking receive has the receiver block until a message is available

Non-blocking is considered asynchronous

Non-blocking send has the sender send the message and continue

Non-blocking receive has the receiver receive a valid message or null

Buffering:

Queue of messages attached to the link; implemented in one of three ways-

Zero capacity – 0 messages Sender must wait for receiver (rendezvous)

Bounded capacity – finite length of n messages Sender must wait if link full

Unbounded capacity – infinite length Sender never waits

© Ashek Mahmud Khan