+ All Categories

Os

Date post: 13-Dec-2014
Category:
Upload: ruffi-insomniac
View: 145 times
Download: 3 times
Share this document with a friend
Description:
BITS 1213 Operating System - Process - Thread - Symmetric Multi Processing - Microkernel Authors: Alauddin Maulana Hirzan B031310530 Muhammad Syaifur Rohman B031310522 Aditya Pradana B031310524 Wendy Sarasjati B031310528 Soraya Arum B031310523
Popular Tags:
47
Group Member: Alauddin Maulana Hirzan B031310530 Muhammad Syaifur Rohman B031310522 Aditya Pradana B031310524 Wendy Sarasjati B031310528 Soraya Arum B031310523 BITS 1213 Operating System
Transcript
Page 1: Os

Group Member: Alauddin Maulana Hirzan B031310530Muhammad Syaifur Rohman B031310522Aditya Pradana B031310524Wendy Sarasjati B031310528Soraya Arum B031310523

BITS 1213 Operating System

Page 2: Os

Main Menu

- Process- Thread- Symmetric Multi Processing- Microkernel

Page 3: Os

Process - Intro

A process is the "heaviest" unit of kernel scheduling. Processes own resources allocated by the operating system. Resources include memory, file handles, sockets, device handles, and windows. Processes do not share address spaces or file resources except through explicit methods such as inheriting file handles or shared memory segments, or mapping the same file in a shared way. Processes are typically preemptively multitasked.

Page 4: Os

Process – Cont'd

Process:- Also called a task- Execution of an individual program- Can be traced list the sequence of instructions that executeProcess, on the other hand, includes:- Current value of Program Counter (PC)- Contents of the processors registers- Value of the variables- The process stack (SP) which typically contains temporary data such as subroutine parameter, return address, and temporary variables.- A data section that contains global variables.

Page 5: Os

Identifier

State

Priority

Program Counter

Memory Pointer

Context Data

I/O Status Info

Accounting Info

…....

Process – Cont'd

While program is executing, this process can be characterized by some elements.Stored in data structure known as Process Control Block (PCB).PCB is created for each process The creation and management of PCB is done by OS

Page 6: Os

PROCESS STATES

l

The Creation and Termination of Processes

l

A Two-State Process Model

l

A Five-State Model

l

Suspended Processes

Page 7: Os

Process – The Creation

Submission of a batch job

User logs on

Created to provide a service such as printing

Process (parents process) creates another process(child process)

Called as process spawning

Page 8: Os

Process – The Termination

Batch job issues Halt (OS service call for termination) instruction

User logs off

Quit an application

Error and fault conditions

Page 9: Os

Process – The Two State Model

l

- Process may be in one of two states

l

Running

l

Not-running

Page 10: Os

The Two State Model – Cont'd

Dispatcher cannot just select the process that has been in the queue the longest because it may be blocked Solution: split Not Running into two states:

Ready – prepare to execute when given opportunity

Blocked/Waiting – process cannot execute until some event occurs (eg. I/O operation or request a resource)

Page 11: Os

Suspended Process

Processor is faster than I/O so all processes could be waiting for I/O

Swap these processes to disk to free up more memory

Blocked state becomes suspend state when swapped to disk

Two new states

Blocked, suspend: blocked processes which have been swapped out to disk

Ready, suspend: ready processes which have been swapped out to disk

Page 12: Os

Suspending Reason

Page 13: Os

Process Control – Modes of Execution

User mode Less-privileged mode User programs typically execute in this mode System mode, control mode, or kernel mode More-privileged mode Kernel of the operating system

Page 14: Os

Process Control – Process Creation

Assign a unique process identifier Allocate space for the process Initialize process control block Set up appropriate linkages Ex: add new process to linked list used for scheduling queue Create or expand other data structures Ex: maintain an accounting file

Page 15: Os

Process Control – Switch a Process

Supervisor call Requests I/O operation such as file open

Trap error occurred from last instruction may cause process to be moved to Exit state

Interrupt event that is external to the running process such as completion of I/O

Page 16: Os

Type of Interrupts

Clock interrupt process has executed for the maximum allowable time slice

I/O interrupt I/O action has occurred

Memory fault memory address is in virtual memory so it must be brought into main memory

Page 17: Os

Execution of the Operating System

Non-process Kernel (old) execute kernel outside of any process operating system code is executed as a separate entity that operates in privileged mode Execution Within User Processes operating system software within context of a user process process executes in privileged mode when executing operating system code Process-Based Operating System major kernel functions are separate processes Useful in multi-processor or multi-computer environment

Page 18: Os

Single Thread VS Multi Thread

Page 19: Os

Single Thread

Single threaded means there is only one thread within the process and it is doing all of the work for the process. The process must wait for the current execution of the thread to complete before it can perform another action.Single threaded results in system idle time and user frustration. For example, assume we are saving a file to a remote network using a single threaded application. Since there is only a single thread in the application, the application will not be able to do anything else while the file is being stored in the remote location. Thus the user waits and begins to wonder if the application is ever going to resume.

Page 20: Os

Multi Thread

In a multithreaded environment, a process is defined as the unit of resource allocation and a unit of protection. The following are associated with processes:

A virtual address space that holds the process image.

Protected access to processors, other processes (for inter-process communication), files, and I/O resources (devices and channels).

Page 21: Os

Thread – Cont'd

Sometime there is an application that needed to run several task in the same time. For example, a web server can have hundreds of clients who access them concurrently. If the web server is running as a process, it has only a single thread then it can only serve one client at a time on a single unit. If there are other clients who wish to make a request, it should wait until the previous client had been served. The solution is to create a web server multi-threading. With the multi-threading web server, it can hear the client's request, while other requests is processing

Page 22: Os

Thread - Introduction

“One example of multithreading is when you are downloading a video while playing it at the same time. Multithreading is also used extensively in computer-generated animations”.

You can imagine multitasking as something that allows processes to run concurrently, while multithreading allows sub-processes to run concurrently. When multiple threads are running concurrently, this is known as multithreading, which is similar to multitasking. Basically, an operating system with multitasking capabilities will allow programs (or processes) to run seemingly at the same time. On the other hand, a single program with multithreading capabilities will allow individual sub-processes (or threads) to run seemingly at the same time.

Page 23: Os

How Multi Thread Works

The multithreading can help because usually a normal HTTP execution contains many I/O. And as you know IO operations are heavy and take much time.

So in practice when you have 1 request in which you need to fetch an instance of class A and an instance of class B if you crete 2 threads one to access A instance and the other to access the instance of class B from database, you can load each instance on a separate thread, this way you will have more probability that thread A executes its code while thread B is blocked on the IO and inversely. So with multithreading you can win IO processing times.

Page 24: Os

Thread – Cont'd

Sometime there is an application that needed to run several task in the same time. For example, a web server can have hundreds of clients who access them concurrently. If the web server is running as a process, it has only a single thread then it can only serve one client at a time on a single unit. If there are other clients who wish to make a request, it should wait until the previous client had been served. The solution is to create a web server multi-threading. With the multi-threading web server, it can hear the client's request, while other requests is processing

Page 25: Os

How Multi Thread Works

The multithreading can help because usually a normal HTTP execution contains many I/O. And as you know IO operations are heavy and take much time.

So in practice when you have 1 request in which you need to fetch an instance of class A and an instance of class B if you crete 2 threads one to access A instance and the other to access the instance of class B from database, you can load each instance on a separate thread, this way you will have more probability that thread A executes its code while thread B is blocked on the IO and inversely. So with multithreading you can win IO processing times.

Page 26: Os

Type of Multi Threading

Many To One In the many-to-one model, many user-level threads are all mapped onto a single kernel thread. Thread management is handled by the thread library in user space, which is very efficient. However, if a blocking system call is made, then the entire process blocks, even if the other user threads would otherwise be able to continue. Because a single kernel thread can operate only on a single CPU, the many-to-one model does not allow individual processes to be split across multiple CPUs.

Page 27: Os

Type of Multi Threading

One to One

The one-to-one model creates a separate kernel thread to handle each user thread. One-to-one model overcomes the problems listed above involving blocking system calls and the splitting of processes across multiple CPUs. Linux and Windows from 95 to XP implement the one-to-one model for threads.

Page 28: Os

Type of Multi Threading

Many to Many

The many-to-many model multiplexes any number of user threads onto an equal or smaller number of kernel threads, combining the best features of the one-to-one and many-to-one models. Users have no restrictions on the number of threads created. Blocking kernel system calls do not block the entire process. Processes can be split across multiple processors.

Page 29: Os

Advantages

a. Responsive . Interactive applications to remain responsive even though the majority of programs are blocked or perform lengthy operation to the user . For example a thread of a web browser can serve user requests while the other thread tried to display an image .b . Resource sharing . Threads share memory and resources with other threads that are owned by the same process . The advantage of sharing code is to allow an application to have several different threads in the same memory location .c . Economical . Making a process requires allocating need memory and resources . The alternative is to use threads , because threads share memory and processing resources that will have be more economical to create and context exchange thread . d. Utilization of multiprocessor architectures . Advantage of multithreading can be greatly increased in multiprocessor architectures , where each thread can run in parallel on the different processor .

Page 30: Os

Disadvantage

a. Kernel threads are generally slower to create and manage than the user threads.b. Transfer of control from one thread to another within same process requires a mode switch to the Kernel.

Page 31: Os

Symmetric Multi Processing

Symmetric Multiprocessing is a computer architecture of multiprocessors which some of them handle similar tasks.  Two or more identical processors are connected to a single shared main memory, have full access to all I/O devices, and are controlled by a single OS instance, and in which all processors are treated equally, with none being reserved for special purposes. Unlike asymmetric processing, any idle processor can be assigned any task, and additional CPUs can be added to improve performance and handle increased loads. Symmetric multiprocessing uses a single operating system and shares common memory and disk input/output resources.

Page 32: Os

Symmetric Multi Processing Cont'd

Symmetric multiprocessing systems are tightly coupled multiprocessor systems with a pool of homogeneous processors running independently, each processor executing different programs and working on different data and with capability of sharing common resources (memory, I/O device, interrupt system and so on) and connected using a system bus or a crossbar.

Page 33: Os

Symmetric Multi Processing Cont'd

Page 34: Os

How SMP Works

In a symmetric multiprocessing environment, the CPU's share the same memory, and as a result code running in one CPU can affect the memory used by another. Uniprocessor and symmetric multiprocessing systems require different programming methods to achieve maximum performance.

Programs running on symmetric multiprocessing systems may experience a performance increase even when they have been written for uniprocessor systems. This is because hardware interrupts that usually suspend program execution while the kernel handles them can execute on an idle processor instead. The effect in most applications is not so much a performance increase as the appearance that the program is running more smoothly. In some applications, some compilers and some distributed computing projects, one will see an improvement by a factor of the number of additional processors.

Page 35: Os

How SMP Works Cont'd

Symmetric multiprocessing systems allow any processor to work on any task no matter where the data for that task are located in memory, provided that each task in the system is not in execution on two or more processors at the same time with proper operating system support, symmetric multiprocessing systems can easily move tasks between processors to balance the workload efficiently.

Page 36: Os

Advantages

Symmetric multiprocessing is one of the cheapest ways to improve hardware performance. This can be done by making the different CPU doing the same job. Symmetric multiprocessing is relatively easy to implement. In situations where more than one program executes at the same time, a symmetric multiprocessing system will have better performance than a uniprocessor because different programs can run on different CPUs simultaneously.

Page 37: Os

Disadvantages

On personal computers, symmetric multiprocessing is less useful for applications that have not been modified. It is useless if the system rarely runs more than one process at a time.

Page 38: Os

Microkernel - Introduction

Kernel is a computer's core program that manages I/O requests from software and translates them into data processing instructions for the CPU and other electronic components of a computer. The kernel is a fundamental part of a modern computer's OS.

Page 39: Os

Type of Kernel

Monolithic Kernels

Microkernel

Hybrid

Exokernel

Page 40: Os

Type of Kernel

Monolithic Kernels

Microkernel

Hybrid

Exokernel

Page 41: Os

Microkernel Cont'd

Microkernel is the near-minimum amount of software that can provide the mechanisms needed to implement an operating system (OS). These mechanisms include low-level address space management, thread management, and inter process communication (IPC). If the hardware provides multiple rings or CPU modes, the microkernel is the only software executing at the most privileged level. A microkernel that is designed for a specific platform or device is only ever going to have what it needs to operate. The microkernel approach consists of defining a simple abstraction over the hardware, with a set of primitives or system calls to implement minimal OS services such as memory management, multitasking, and inter-process communication. Other services, including those normally provided by the kernel, such as networking, are implemented in user-space programs, and referred to as servers.

Page 42: Os

Microkernel Cont'd

Microkernel is the near-minimum amount of software that can provide the mechanisms needed to implement an operating system (OS). These mechanisms include low-level address space management, thread management, and inter process communication (IPC). If the hardware provides multiple rings or CPU modes, the microkernel is the only software executing at the most privileged level. A microkernel that is designed for a specific platform or device is only ever going to have what it needs to operate. The microkernel approach consists of defining a simple abstraction over the hardware, with a set of primitives or system calls to implement minimal OS services such as memory management, multitasking, and inter-process communication. Other services, including those normally provided by the kernel, such as networking, are implemented in user-space programs, and referred to as servers.

Page 43: Os

Advantages

Service separation has the advantage that if one service (called a server) fails others can still work so reliability is the primary feature. For example if a device driver crashes does not cause the entire system to crash.

Only that driver need to be restarted rather than having the entire system die. This means more persistence as one server can be substituted with another. It also means maintenance is easier.

Different services are built into special modules which can be loaded or unloaded when needed. Patches can be tested separately then swapped to take over on a production instance.

Message passing allows independent communication and allows extensibility

The fact that there is no need to reboot the kernel implies rapid test and development.

Easy and faster integration with 3d party modules.

Page 44: Os

Disadvantages

Memory foot print is large

Potential performance loss (more software interfaces due to message passing)

Message passing bugs are not easy to fix

Process management is complex

Page 45: Os

Microkernel Diagram

Page 46: Os

Microkernel Diagram Cont'd

Page 47: Os

References

l http://en.wikipedia.org/wiki/Thread_(computing)l http://ashishkhandelwal.arkutil.coml http://www.cs.uic.edu/~jbell/CourseNotes/OperatingSystems/4_Threads.html

l http://www.slideshare.net/sartakov/01-intro1-14682045

l http://beckellroom.blogspot.com/2009/01/pengertian-tentang-kernel-kernel-adalah.html

l http://www.8bitavenue.com/2012/11/microkernel-vs-monolithic-os-architectures/

l http://en.wikipedia.org/wiki/Kernel_(computing)#Monolithic_kernels

l http://en.wikipedia.org/wiki/File:OS-structure.svg


Recommended