process, threads, symmetric multiprocessing and microkernels in operating system

44
FACULTY OF INFORMATION AND COMMUNICATION TECHNOLOGY UTeM FACULTY OF INFORMATION AND COMMUNICATION TECHNOLOGY OPERATING SYSTEM ( BITS 1213 ) Student’s Name Matric Number Aniyah binti Amirhussin B031310042 Azwana binti Ahmad B031310071 Daliah binti Daud B031310491 Goh Yu Fern B031310113 Nik Siti Noor Fadhillah binti Md Saad B031310496 Rahilda Nadhirah Norizzaty binti B031310111 Lecturer’s Name: Dr. Nurul Azma binti Zakaria

Upload: lieyah-daliah

Post on 06-May-2015

1.596 views

Category:

Education


0 download

TRANSCRIPT

Page 1: Process, Threads, Symmetric Multiprocessing and Microkernels in Operating System

FAC

ULT

Y O

F I

NFO

RM

ATIO

N A

ND

C

OM

MU

NIC

ATIO

N T

EC

HN

OLO

GY

UTe

M

FACULTY OF INFORMATION AND COMMUNICATION TECHNOLOGY

OPERATING SYSTEM( BITS 1213 )

Student’s Name Matric Number

Aniyah binti Amirhussin B031310042

Azwana binti Ahmad B031310071

Daliah binti Daud B031310491

Goh Yu Fern B031310113

Nik Siti Noor Fadhillah binti Md Saad B031310496

Rahilda Nadhirah Norizzaty binti Rahiddin

B031310111

Lecturer’s Name: Dr. Nurul Azma binti Zakaria

Page 2: Process, Threads, Symmetric Multiprocessing and Microkernels in Operating System

TOPICS COVERED:

1.0 PROCESS2.0 THREADS3.0 SYMMETRIC MULTIPROCESSING4.0 MICROKERNELS

1

Page 3: Process, Threads, Symmetric Multiprocessing and Microkernels in Operating System

1.0 PROCESS

Also known as task. Execution of an individual program. Contains program code and its current activity Can be traced to list the sequence of instructions

that execute.

Depending on the operating system (OS), a process may be made up of multiple threads of execution that execute instructions concurrently.

2

Page 4: Process, Threads, Symmetric Multiprocessing and Microkernels in Operating System

DETAILED DESCRIPTION AND HOW IT WORKS

Process Control Block (PCB)

While program is executing, processes are stored in data structure known as PCB.

PCB is created for each process. The creation and management of PCB is done by

OS PCB has sufficient information. Thus, it’s possible

to interrupt a running process and later resume execution as if there is no interruption.

Process = Program code + Associated data + PCB

3

Page 5: Process, Threads, Symmetric Multiprocessing and Microkernels in Operating System

An interrupted process in PCB

Change to other value,For example: blocked or ready

Current values are saved in appropriate fields of corresponding PCB

OS is now free to put other process in Running state

4

Page 6: Process, Threads, Symmetric Multiprocessing and Microkernels in Operating System

Dispatcher (short-term schedule)

OS program that moves the processor from one process to another.

Prevents a single process from monopolizing processor time.

Decides who goes next according to a scheduling algorithm.

CPU will execute instructions from the dispatcher while switching from process A to process B.

5

Page 7: Process, Threads, Symmetric Multiprocessing and Microkernels in Operating System

PROCESS STATES1. The Creation and Termination of Process

Process Creation* Process (parent) creates another process (child) called as process spawning.

* Submission of batch job and user is logs on.

* It is created to provide service such as printing.

Process Termination* Batch job issues Halt instruction (OS service call for termination) and user is logs off. * Occurs when quitting an application or error and faults condition appear.

Reasons for Process Termination* Normal completion* Time limit exceeded* Memory unavailable* Protection error (eg: write to read-only file)* I/O failure

6

Page 8: Process, Threads, Symmetric Multiprocessing and Microkernels in Operating System

2. A Two-State Process Model

o Process may be in one of two states: running, not running.

o Dispatcher cannot select the process that is in the queue the longest because it may be blocked

o Solution: split Not Running into two states: i) Ready – prepare to execute when given opportunityii) Blocked/Waiting – process cannot execute until some event occurs

PROCESS STATES

7

Page 9: Process, Threads, Symmetric Multiprocessing and Microkernels in Operating System

3. A Five-State Process Model

PROCESS STATES

8

Page 10: Process, Threads, Symmetric Multiprocessing and Microkernels in Operating System

4. Suspended Process

Processor faster than I/O (processes wait for I/O) Swap these processes to disk to free up memory Block state -> suspend state, when swap to disk Two new state - Blocked, suspend: blocked processes which have been swapped out to disk - Ready, suspend: ready processes which have been swapped out to disk

PROCESS STATES

9

Page 11: Process, Threads, Symmetric Multiprocessing and Microkernels in Operating System

One Suspend State

10

Page 12: Process, Threads, Symmetric Multiprocessing and Microkernels in Operating System

Two Suspend State

11

Page 13: Process, Threads, Symmetric Multiprocessing and Microkernels in Operating System

OS have tables for managing processes and resources.

1. Memory tables - Allocation of main and secondary memory to processes - Protection attributes for access to shared

memory regions - Information needed to manage virtual memory

2. I/O tables - I/O device is available or assigned - Status of I/O operation - Location in main memory being used as the

source or destination of the I/O transfer

OPERATING SYSTEM CONTROL STRUCTURE

12

Page 14: Process, Threads, Symmetric Multiprocessing and Microkernels in Operating System

3. File tables - Existence of files - Location on secondary memory - Current Status - Attributes - Sometimes this information is maintained by a file- management system

4. Process tables - Where process is located - Attributes necessary for its management

- Process ID- Process state- Location in memory

13

Page 15: Process, Threads, Symmetric Multiprocessing and Microkernels in Operating System

1. Modes of Execution

i. User Mode* Less-privileged mode* User programs typically execute in

this mode

ii. System mode, Control mode or Kernel Mode* More-privileged mode* Kernel of the OS

PROCESS CONTROL

14

Page 16: Process, Threads, Symmetric Multiprocessing and Microkernels in Operating System

2. Process Creation Assign a unique process identifier Allocate space for the process Initialize process control block Set up appropriate linkages

Eg: add new process to linked list used for scheduling queue

Create or expand other data structuresEg: maintain an accounting file

PROCESS CONTROL

15

Page 17: Process, Threads, Symmetric Multiprocessing and Microkernels in Operating System

2.0 THREADS

INTRODUCTION

A thread is the smallest unit of processing that can be performed in an OS.

An execution state (running, ready, etc.) Has an execution stack. In most modern operating systems, a thread

exists within a process - that is, a single process may contain multiple threads.

16

Page 18: Process, Threads, Symmetric Multiprocessing and Microkernels in Operating System

DETAILED DESCRIPTION

On a single processor, multi threading generally occurs by as in multitasking, the processor switches between different threads.

This context switching generally happens frequently enough that the user perceives the threads or tasks to be running at the same time.

On the multiprocessor or mutli-core system, the threads or task actually do run at the same time, with each processor or core running a particular thread or task.

17

Page 19: Process, Threads, Symmetric Multiprocessing and Microkernels in Operating System

Single and Multithreading Processes

18

Page 20: Process, Threads, Symmetric Multiprocessing and Microkernels in Operating System

MULTITHREADING VS. SINGLE THREADING

• Multithreading: when OS supports multiple threads of execution within a single process.

• Single threading: when the OS does not recognize the concept of thread.

• MS-DOS supports a single thread.

• UNIX supports multiple user processes but only supports one thread per process

• Windows 2000, Solaris, Linux, Mach, and OS/2 support multiple threads

19

Page 21: Process, Threads, Symmetric Multiprocessing and Microkernels in Operating System

Thread Control Block contains a register image, thread priority and thread state information

20

Page 22: Process, Threads, Symmetric Multiprocessing and Microkernels in Operating System

ADVANTAGES

Thread minimize context switching time. Use of threads provides concurrency within a

process. Efficient communication. Economy- It is more economical to create and

context switch threads. Utilization of multiprocessor architectures to a

greater scale and efficiency.

21

Page 23: Process, Threads, Symmetric Multiprocessing and Microkernels in Operating System

Three key states: running, ready, blocked No suspend state since all threads share the

same address space. Suspending a process involves suspending all

threads of the process. Termination of a process, terminates all threads

within the process. States associated with a change in thread state:

i. Spawn -spawn another threadii. Blockiii. Unblockiv. Finish

THREAD STATES

22

Page 24: Process, Threads, Symmetric Multiprocessing and Microkernels in Operating System

Contains code for:

1. Creating and destroying threads.2. Passing messages and data between

threads.3. Scheduling thread execution.4. Saving and restoring thread context.

THREAD LIBRARY

23

Page 25: Process, Threads, Symmetric Multiprocessing and Microkernels in Operating System

1. User Level Threads – (user managed thread)

Diagram Of User-level Thread

o All thread management is done by the application.o The kernel is not aware of the existence of threads.o OS only schedules the process, not the threads within

process.o Programmer using a thread library to manage threads

(create,delete,schedule)

TYPE OF THREAD

24

Page 26: Process, Threads, Symmetric Multiprocessing and Microkernels in Operating System

ADVANTAGES

User-level threads can be implemented on operating system that does not support threads.

Implementing user-level threads does not require modification of operating system where everything is managed by the thread library.

Simple representation which the thread is represented by a the thread ID, program counter, register, stack , all stored in user process address space.

Simple management where creating new threads, switching threads and synchronization between threads can be done without intervention of the kernel.

Fast and efficient where switching thread is much more inexpensive compared to a system call.DISADVANTAGES

There is a lack of coordination between threads and operating system kernel. A process gets one time slice no matter it has 1 thread or 10000 threads within it. It is up to the thread itself to give up the control to other threads.

If one thread made a blocking system call, the entire process can be blocked in the kernel, even if other threads in the same process are in the ready state.

25

Page 27: Process, Threads, Symmetric Multiprocessing and Microkernels in Operating System

2. Kernel-Level Threads (OS managed threads acting on kernel, an OS core)

All thread management is done by the kernel. Kernel maintains context information for the

process and the threads. No thread library but an API to the kernel thread

facility. Switching between threads requires the kernel. Scheduling is done on a thread basis.

26

Page 28: Process, Threads, Symmetric Multiprocessing and Microkernels in Operating System

ADVANTAGES

Kernel can simultaneously schedule multiple threads from the same process on multiple processes.

If one threads in a process is blocked, the Kernel can schedule another threads of the same process.

Kernel routines themselves can multithreaded.

DISADVANTAGES

Kernel threads are generally slower to create and manage than the user threads.

Transfer of control from one thread to another within same process requires a mode switch to the Kernel.

27

Page 29: Process, Threads, Symmetric Multiprocessing and Microkernels in Operating System

User Level VS Kernel Level Thread

User Level Threads Kernel Level Thread

Faster to create and manage. Slower to create and manage.

Implementation is by a thread library at the user level.

OS supports creation of kernel thread.

Generic and can run on any OS. Specific to the OS.

Multi-threaded application can not take advantage of multiprocessing.

Kernel routines themselves can be multithreaded.

28

Page 30: Process, Threads, Symmetric Multiprocessing and Microkernels in Operating System

1. Many to One Relationship

Many user-level threads mapped to single kernel threads.

MULTITHREADING MODELS

29

Page 31: Process, Threads, Symmetric Multiprocessing and Microkernels in Operating System

2. Many to Many Relationship

Allows many user level threads to be mapped to many kernel threads.

Allows the operating system to create a sufficient number of kernel threads.

MULTITHREADING MODELS

30

Page 32: Process, Threads, Symmetric Multiprocessing and Microkernels in Operating System

2. One to One Relationship

Each user-level thread maps to kernel threads. Allow another threads to run if block. Run parallel

MULTITHREADING MODELS

31

Page 33: Process, Threads, Symmetric Multiprocessing and Microkernels in Operating System

3.0 SYMMETRIC MULTIPROCESSING

INTRODUCTION

Each CPU has equal access to resources. Each CPU determines what to run using a

standard algorithm. Kernel can execute on any processor.

- Allowing portions of the kernel to execute in parallel. Typically each processor does self-scheduling

from the pool of available process or threads.Proc 1 Proc 2 Proc 3 Proc 4

Mem 1 Mem 2 Mem 3 Mem 4 32

Page 34: Process, Threads, Symmetric Multiprocessing and Microkernels in Operating System

Symmetric Multiprocessor Organization

33

Page 35: Process, Threads, Symmetric Multiprocessing and Microkernels in Operating System

MULTIPROCESSOR OS DESIGN CONSIDERATIONS

1. Simultaneous concurrent processes or threads

2. Scheduling3. Synchronization4. Memory management5. Reliability and fault tolerance

34

Page 36: Process, Threads, Symmetric Multiprocessing and Microkernels in Operating System

Symmetric Shared-Memory Architectures

From multiple boards on a shared bus to multiple processors inside a single chip.

Caches both

1. Private data are used by a single processor

2. Shared data are used by multiple processors

Caching shared data reduces latency to shared data,

memory bandwidth for shared data, and interconnect bandwidth

cache coherence problem 35

Page 37: Process, Threads, Symmetric Multiprocessing and Microkernels in Operating System

ADVANTAGES

High reliability

Fault tolerant support is straight forward

Balanced workload

DISADVANTAGES

Resources conflicts. Example: memory and I/O

Complex implementation

36

Page 38: Process, Threads, Symmetric Multiprocessing and Microkernels in Operating System

Involves synchronization of access to global ready queue

Eg: only one processor must execute a job at one time

Processors: CPU1, CPU2, CPU3, …

When a processor accesses the ready queue:1. If they attempt access to the ready queue, all

other processors (CPU2, CPU3, …) must wait; denied access.

2. Accessing processor (eg. CPU1) removes a process from ready queue, and dispatch’s process on itself.

3. Just before dispatch, that processor makes ready queue again available for use by the other CPU’s.

Synchronization Issues

37

Page 39: Process, Threads, Symmetric Multiprocessing and Microkernels in Operating System

4.0 MICROKERNELS

DETAILED DESCRIPTION

This structures the operating system by removing all nonessential portions of the kernel and implementing them as system and user and user level programs.

Provide minimal process and memory management & communication facility

Communication between components if the OS is provided by massage passing

38

Page 40: Process, Threads, Symmetric Multiprocessing and Microkernels in Operating System

ADVANTAGES & DISADVANTAGES

ADVANTAGES

Extending the OS becomes much easier.

Any changes to the kernel tend to be fewer, since the kernel is smaller.

Provides more security and reability

MAIN DISADVANTAGES

It is poor performance due to increase system overhead from message passing.

39

Page 41: Process, Threads, Symmetric Multiprocessing and Microkernels in Operating System

KERNEL ARCHITECTURE

40

Page 42: Process, Threads, Symmetric Multiprocessing and Microkernels in Operating System

FIGURE A

Operating systems developed in the mid to late 1950s were designed with little concern about structure.

The problems caused by mutual dependence and interaction were grossly underestimated.

In these monolithic operating systems, virtually any procedure can call any other procedure – the approach

Modular programming techniques were needed to handle this scale of software development.

Layered operating systems were developed in which functions are organized hierarchically and interaction only takes place between adjacent layers.

Most or all of the layers execute in kernel mode.

PROBLEM: Major changes in one layer can have numerous effects on code in adjacent layers - many difficult to trace.And security is difficult to build in because of the many interactions between adjacent layers.

41

Page 43: Process, Threads, Symmetric Multiprocessing and Microkernels in Operating System

FIGURE B

In a Microkernel - only absolutely essential core OS functions should be in the kernel.

Less essential services and applications are built on the microkernel and execute in user mode.

Common characteristic is that many services that traditionally have been part of the OS are now external subsystems that interact with the kernel and with each other;

These include device drivers, file systems, virtual memory manager, windowing system, and security services.

The microkernel functions as a message exchange: It validates messages, Passes them between components, Grants access to hardware.

The microkernel also performs a protection function; it prevents message passing unless exchange is allowed.

42

Page 44: Process, Threads, Symmetric Multiprocessing and Microkernels in Operating System

FAC

ULT

Y O

F I

NFO

RM

ATIO

N A

ND

C

OM

MU

NIC

ATIO

N T

EC

HN

OLO

GY

UTe

M

THE END

Thank you for reading this slides.(^_^)