Presentation is loading. Please wait.

Presentation is loading. Please wait.

Operating Systems (OS) Threads, SMP, and Microkernel, Unix Kernel

Similar presentations


Presentation on theme: "Operating Systems (OS) Threads, SMP, and Microkernel, Unix Kernel"— Presentation transcript:

1 Operating Systems (OS) Threads, SMP, and Microkernel, Unix Kernel
phones off (please) COMP5102/5122 Lecture 5 Operating Systems (OS) Threads, SMP, and Microkernel, Unix Kernel

2 © De Montfort University, 2005
Lecture Outline Threads, SMP Microkernels Unix Kernel IPC and deadlock © De Montfort University, 2005 Comp5102/ L5

3 © De Montfort University, 2005
Consider A Process is a unit of: Resource ownership Dispatching (execution path, state) What if we treat each independently? Process resource ownership Thread dispatch and execution unit © De Montfort University, 2005 Comp5102/ L5

4 © De Montfort University, 2005
Threads Sometimes called a lightweight process smaller execution unit than a process Consists of: program counter register set stack space Threads share: memory space code section OS resources(open files, signals, etc.) © De Montfort University, 2005 Comp5102/ L5

5 © De Montfort University, 2005
Multithreading Most OS support multiple threads of execution within a single process MS-DOS supports a single thread UNIX supports multiple user processes but only supports one thread per process Windows NT, Solaris, Linux, Mac, and OS/2 support multiple threads © De Montfort University, 2005 Comp5102/ L5

6 Threads Process 0 Process 1 regs regs regs mem code code memory
All threads in a process share the same memory space © De Montfort University, 2005 Comp5102/ L5

7 Single Threaded and Multithreaded Process Models
Control Block Thread Control Block Thread Control Block Process Control Block User Stack Process Control Block User Stack User Stack User Stack User Address Space Kernel Stack User Address Space Kernel Stack Kernel Stack Kernel Stack © De Montfort University, 2005 Comp5102/ L5

8 © De Montfort University, 2005
Why use threads? Parallelism Uses fewer resources Faster context switch Threads can work together easier Modularity © De Montfort University, 2005 Comp5102/ L5

9 © De Montfort University, 2005
Parallel Processing The processing of program instructions by dividing them among multiple processors with the objective of running a program in less time. Rather than speeding up hardware you could just add more processors to speed up the system. © De Montfort University, 2005 Comp5102/ L5

10 Flynn’s Classification
Based on the number of instruction streams and the number of data streams. © De Montfort University, 2005 Comp5102/ L5

11 Categories of Computer Systems
Single Instruction Single Data (SISD) single processor executes a single instruction stream to operate on data stored in a single memory Single Instruction Multiple Data (SIMD) each instruction is executed on a different set of data by the different processors © De Montfort University, 2005 Comp5102/ L5

12 Categories of Computer …
Multiple Instruction Single Data (MISD) a sequence of data is transmitted to a set of processors, each of which executes a different instruction sequence. Never implemented Multiple Instruction Multiple Data (MIMD) a set of processors simultaneously execute different instruction sequences on different data sets © De Montfort University, 2005 Comp5102/ L5

13 © De Montfort University, 2005
Comp5102/ L5

14 Symmetric Multiprocessing
SMP is the processing of programs by multiple processors that share a common operating system and memory. Kernel can execute on any processor Typically each processor does self-scheduling from the pool of available process or threads Timer interrupt Ready queue © De Montfort University, 2005 Comp5102/ L5

15 Symmetric Multiprocessor Organization
. . . Processor Cache Cache Cache I/O adaptor Main Memory I/O Subsystem © De Montfort University, 2005 Comp5102/ L5

16 Multiprocessor Operating System
Design Considerations: Simultaneous concurrent processes or threads Scheduling Synchronization Memory Management Reliability and Fault Tolerance © De Montfort University, 2005 Comp5102/ L5

17 © De Montfort University, 2005
Microkernel Small operating system core Contains only essential OS functions Many services traditionally included in the operating system are now external subsystems device drivers file systems virtual memory manager windowing system and security services © De Montfort University, 2005 Comp5102/ L5

18 © De Montfort University, 2005
Microkernel OS U s e r P o c D e v i c r V i r t u a l M e m P r o c e s S v F i l e S y s t m User Processes File System IPC I/O & Device Mgmt Virtual Memory Process Management Microkernel Hardware Hardware Kernel Mode User Mode © De Montfort University, 2005 Comp5102/ L5

19 © De Montfort University, 2005
Unix Kernel Hardware is surrounded by the OS which is called the kernel Comes with a number of services and interfaces Shell C compiler strictly speaking, the kernel is Unix monolithic in design; grown to a massive block © De Montfort University, 2005 Comp5102/ L5

20 © De Montfort University, 2005
Unix … © De Montfort University, 2005 Comp5102/ L5

21 © De Montfort University, 2005
Unix … The Kernel can be split into two sections :- Machine dependent hardware control, incorporating low level i/o, device drivers, interrupt handlers, context switching and some memory management. Machine independent the rest (see diagram in the book) © De Montfort University, 2005 Comp5102/ L5

22 © De Montfort University, 2005
Kernel Structures The key structure is the process table contains an entry for every process contains information, accessible to the kernel. The user area contains fields relating to the current process which can be swapped to disk © De Montfort University, 2005 Comp5102/ L5

23 Process table entries:-
Scheduling details: priority, CPU usage, sleeping etc. Identifiers: process id, parent's id, user id. Memory usage Signals: signals sent to the process but not yet dealt with. Synchronisation © De Montfort University, 2005 Comp5102/ L5

24 © De Montfort University, 2005
The user area :- machine registers in user state; system call state - parameters and results; file descriptor table - current directory; permission modes for creating files; accounting information - user time, system time; kernel stack. © De Montfort University, 2005 Comp5102/ L5

25 © De Montfort University, 2005
User processes - pre-emptive scheduling. Unpriviledged. Kernel - hardware independent - runs until completed or blocked. Priviledged. Kernel - hardware dependent - Never scheduled. Cannot block. Deals with interrupts. Runs on kernel stack, in kernel address space. © De Montfort University, 2005 Comp5102/ L5

26 © De Montfort University, 2005
Interrupt priorities high priority Machine errors Clock Disk Network Terminals low priority Software Interrupt © De Montfort University, 2005 Comp5102/ L5

27 © De Montfort University, 2005
Sleep And Wakeup process executing in kernel may need to wait for some event. executes the sleep routine. state of process is changed to blocked scheduler selects another process. When the event occurs the interrupt routine executes: wakeup routine executed by interrupt process changed to ready state. © De Montfort University, 2005 Comp5102/ L5

28 © De Montfort University, 2005
Kernel sets the priority of the sleeping process according to the reason for sleeping. e.g. we could have 3 processes contending for a locked buffer :- © De Montfort University, 2005 Comp5102/ L5

29 © De Montfort University, 2005
process A process B process C buffer locked sleeps buffer locked, sleeps buffer unlocked. A, B, C woken - ready to run ready to run ready to run Runs - locks buffer sleeps for some reason Runs - buffer locked - sleeps Runs - buffer locked - sleeps © De Montfort University, 2005 Comp5102/ L5

30 © De Montfort University, 2005
Summary Symmetric multiprocessing is a method of organising a multiprocessing system such that any process (or thread) can run on any processor; this includes kernel codes and processes. An SMP architecture raises new operating systems design issues and provides greater performance than a uniprocessor system under similar conditions. In recent years there has been much interest in the microkernel approach to operating system design. In its pure form, a microkernel operating system consists of a very small microkernel that runs in kernel mode and that contains only the most essential and critical operating system functions. © De Montfort University, 2005 Comp5102/ L5

31 Benefits of Microkernel Organization (Appendix A)
Uniform interface on request made by a process all services are provided by means of message passing Extensibility allows the addition of new services Flexibility existing features can be subtracted Portability changes needed to port the system to a new processor is changed in the microkernel - not in the other services Reliability modular design small microkernel can be rigorously tested Distributed system support message are sent without knowing what the target machine is Object-oriented operating system components are objects with clearly defined interfaces that can be interconnected to form software © De Montfort University, 2005 Comp5102/ L5

32 © De Montfort University, 2005
Assgnment: Hand in in a folder: One page explaining the shell programming and what is your work all about. Don’t worry about bundling! © De Montfort University, 2005 Comp5102/ L5

33 © De Montfort University, 2005
Hand in a floppy disk, containing your programs. Listing of your programs. Make sure that you have commented the programs well and say in your introductory page how to run the programs. © De Montfort University, 2005 Comp5102/ L5

34 © De Montfort University, 2005
In your initialise file: echo "0" > $HOME/trash/counter Then in your del file to increment counter for each file deleted: C=$HOME/trash/counter CT=`cat $C` CT=`expr $CT + 1` echo "$CT" > $HOME/trash/counter © De Montfort University, 2005 Comp5102/ L5


Download ppt "Operating Systems (OS) Threads, SMP, and Microkernel, Unix Kernel"

Similar presentations


Ads by Google