operating systems: intro 1 operating systems concepts and principles –monolithic and micro kernels...
TRANSCRIPT
![Page 1: Operating Systems: Intro 1 Operating Systems Concepts and Principles –monolithic and micro kernels –processes and threads »their management and synchronisation](https://reader035.vdocuments.site/reader035/viewer/2022062404/551ae3085503466b6a8b5cd4/html5/thumbnails/1.jpg)
Operating Systems: Intro
1
Operating Systems
•Concepts and Principles
–monolithic and micro kernels
–processes and threads
»their management and synchronisation
»interprocess communication
–interrupts and signals
–virtual memory - paging and segmentation
•Implementation Techniques
–resource allocation
–time management - process scheduling
–memory management - usage models and page allocation
–file systems
–case studies - Kops, Linux, NT etc.
![Page 2: Operating Systems: Intro 1 Operating Systems Concepts and Principles –monolithic and micro kernels –processes and threads »their management and synchronisation](https://reader035.vdocuments.site/reader035/viewer/2022062404/551ae3085503466b6a8b5cd4/html5/thumbnails/2.jpg)
Operating Systems: Intro
2
Coursework
•To Be Announced
–probably involving some programming
–deadline - mid-term
•Essay - in-depth comparison of PDA Operating Systems
–structure, scheduling, memory management, security etc.
–deadline - end of term
Tutorials only when needed
![Page 3: Operating Systems: Intro 1 Operating Systems Concepts and Principles –monolithic and micro kernels –processes and threads »their management and synchronisation](https://reader035.vdocuments.site/reader035/viewer/2022062404/551ae3085503466b6a8b5cd4/html5/thumbnails/3.jpg)
Operating Systems: Intro
3
Textbooks
•William Stallings, Operating Systems, Internals & Design Principles, 4th edition, Prentice-Hall, 2001.
•Abraham Silberschatz & Peter Galvin, Operating System Concepts, 5th edition, Addison-Wesley, 1998.
•Gary Nutt, Operating Systems, A Modern Perspective, 2nd edition, Addison-Wesley, 2000.
•D.A.Solomon & M.E.Russinovitch, Inside Windows 2000, 3rd edition, MicroSoft Press, 2000.
•D.Boling, Programming MicroSoft Windows CE, MicroSoft Press, 1998.
•Michael Beck et al., Linux Kernel Internals, 2nd edition, Addison-Wesley, 1997.
•John O’Gorman, Operating Systems with Linux, Palgrave, 2001.
![Page 4: Operating Systems: Intro 1 Operating Systems Concepts and Principles –monolithic and micro kernels –processes and threads »their management and synchronisation](https://reader035.vdocuments.site/reader035/viewer/2022062404/551ae3085503466b6a8b5cd4/html5/thumbnails/4.jpg)
Operating Systems: Intro
4
Motivation
•An Automated Teller Machine (ATM) process
–process to deposit an amount into an account:
deposit (account, amount) {
read ( account, balance ); // read balance from database
balance = balance + amount; // add deposit amount
write (account, balance ); // update database
}
–process to withdraw an amount from an account:
withdraw ( account, amount ) {
read (account, balance); // read balance from database
balance = balance - amount; // subtract withdrawal amount
write ( account, balance); // update database
}
–concurrent processes?
![Page 5: Operating Systems: Intro 1 Operating Systems Concepts and Principles –monolithic and micro kernels –processes and threads »their management and synchronisation](https://reader035.vdocuments.site/reader035/viewer/2022062404/551ae3085503466b6a8b5cd4/html5/thumbnails/5.jpg)
Operating Systems: Intro
5
•To sum the elements of a matrix
–in row order:sum = 0;for (row=0; row<row_max; row++) { for (col=0; col<col_max; col++) { sum = sum + array[row,col];} }cout << “Array Sum =“ << sum << endl;
–in column order:sum = 0;for (col=0; col<cp;_max; col++) { for (row=0; row<row_max; row++) { sum = sum + array[row,col];} }cout << “Array Sum =“ << sum << endl;
–any difference?
![Page 6: Operating Systems: Intro 1 Operating Systems Concepts and Principles –monolithic and micro kernels –processes and threads »their management and synchronisation](https://reader035.vdocuments.site/reader035/viewer/2022062404/551ae3085503466b6a8b5cd4/html5/thumbnails/6.jpg)
Operating Systems: Intro
6
Operating Systems
•Main purpose is to facilitate the execution of user application programs
–bare hardware is extremely messy and difficult for users to program
»processors
»memory
»peripheral devices
»concurrency
»interrupts
»files
»networks
![Page 7: Operating Systems: Intro 1 Operating Systems Concepts and Principles –monolithic and micro kernels –processes and threads »their management and synchronisation](https://reader035.vdocuments.site/reader035/viewer/2022062404/551ae3085503466b6a8b5cd4/html5/thumbnails/7.jpg)
Operating Systems: Intro
7
•Modern operating systems structured around concept of a process
process = “program in execution”
–a process is not the same as a program
–programs are passive, processes are active
–a process consists of an executable program, associated data and its execution context
•A process runs in a framework which provides a Virtual Machine for it
–a Virtual Machine is a simplified machine with:
»user-level processor
»virtual memory
»high-level facilities
»a machine with one user
![Page 8: Operating Systems: Intro 1 Operating Systems Concepts and Principles –monolithic and micro kernels –processes and threads »their management and synchronisation](https://reader035.vdocuments.site/reader035/viewer/2022062404/551ae3085503466b6a8b5cd4/html5/thumbnails/8.jpg)
Operating Systems: Intro
8
•An OS supports execution of many concurrent processes
–many co-existing virtual machines
–each run alternately - pseudo-concurrently
–OS issues revolve around process management
»how and when to create & destroy processes
»how to avoid interference between processes
»how to achieve cooperation between processes
![Page 9: Operating Systems: Intro 1 Operating Systems Concepts and Principles –monolithic and micro kernels –processes and threads »their management and synchronisation](https://reader035.vdocuments.site/reader035/viewer/2022062404/551ae3085503466b6a8b5cd4/html5/thumbnails/9.jpg)
Operating Systems: Intro
9
•An OS manages resource requirements of processes
–time
–memory
–files
–I/O device access
–processors
•An OS aims to be efficient
–for user
–for system manager
![Page 10: Operating Systems: Intro 1 Operating Systems Concepts and Principles –monolithic and micro kernels –processes and threads »their management and synchronisation](https://reader035.vdocuments.site/reader035/viewer/2022062404/551ae3085503466b6a8b5cd4/html5/thumbnails/10.jpg)
Operating Systems: Intro
10
•A process can be in one of several states
–newly created
–running
–blocked
»waiting for some event to occur
»in main memory
»moved out to disc
–ready to run
–terminated
![Page 11: Operating Systems: Intro 1 Operating Systems Concepts and Principles –monolithic and micro kernels –processes and threads »their management and synchronisation](https://reader035.vdocuments.site/reader035/viewer/2022062404/551ae3085503466b6a8b5cd4/html5/thumbnails/11.jpg)
Operating Systems: Intro
11
•Overheads in swapping execution between processes
–saving and restoring contexts
–loss of cache contents
•Places limits on how often execution should be swapped
–performance will plummet if too frequent
![Page 12: Operating Systems: Intro 1 Operating Systems Concepts and Principles –monolithic and micro kernels –processes and threads »their management and synchronisation](https://reader035.vdocuments.site/reader035/viewer/2022062404/551ae3085503466b6a8b5cd4/html5/thumbnails/12.jpg)
Operating Systems: Intro
12
•A relatively new mechanism to improve overheads is the Thread
–a lightweight process
–several threads within one process or virtual machine
–much smaller context to preserve
–must cooperate
–must not compete
–can be separately scheduled
–can run concurrently on multiprocessor systems
–often also a very convenient programming paradigm
![Page 13: Operating Systems: Intro 1 Operating Systems Concepts and Principles –monolithic and micro kernels –processes and threads »their management and synchronisation](https://reader035.vdocuments.site/reader035/viewer/2022062404/551ae3085503466b6a8b5cd4/html5/thumbnails/13.jpg)
Operating Systems: Intro
13
Interfaces
Hardware
Operating System
process process process process process
application application application application application
user user user user user
![Page 14: Operating Systems: Intro 1 Operating Systems Concepts and Principles –monolithic and micro kernels –processes and threads »their management and synchronisation](https://reader035.vdocuments.site/reader035/viewer/2022062404/551ae3085503466b6a8b5cd4/html5/thumbnails/14.jpg)
Operating Systems: Intro
14
•Communications between OS and processes
–from process to OS - system calls
–from OS to process - signals
![Page 15: Operating Systems: Intro 1 Operating Systems Concepts and Principles –monolithic and micro kernels –processes and threads »their management and synchronisation](https://reader035.vdocuments.site/reader035/viewer/2022062404/551ae3085503466b6a8b5cd4/html5/thumbnails/15.jpg)
Operating Systems: Intro
15
•Communications between OS and Hardware
–from OS to hardware - register & status settings
–from hardware to OS - interrupts and exceptions
![Page 16: Operating Systems: Intro 1 Operating Systems Concepts and Principles –monolithic and micro kernels –processes and threads »their management and synchronisation](https://reader035.vdocuments.site/reader035/viewer/2022062404/551ae3085503466b6a8b5cd4/html5/thumbnails/16.jpg)
Operating Systems: Intro
16
•Communications between processes
–signals
–message passing
–via buffers
–shared virtual memory
–pipes
–sockets
•Communications between users and processes
–keyboard, mouse, touch-screen
–bit-mapped text and graphics display screens with windows
–printers, plotters
![Page 17: Operating Systems: Intro 1 Operating Systems Concepts and Principles –monolithic and micro kernels –processes and threads »their management and synchronisation](https://reader035.vdocuments.site/reader035/viewer/2022062404/551ae3085503466b6a8b5cd4/html5/thumbnails/17.jpg)
Operating Systems: Intro
17
Interrupts
•An interruption in the normal execution flow of a processor
–a mechanism for causing the processor to suspend its current computation and take up some new task
»old context must be preserved
»control can be returned to the original task at some later time
»new context started
•Reasons:
–control of asynchronous I/O devices
–exceptional conditions arising from execution
![Page 18: Operating Systems: Intro 1 Operating Systems Concepts and Principles –monolithic and micro kernels –processes and threads »their management and synchronisation](https://reader035.vdocuments.site/reader035/viewer/2022062404/551ae3085503466b6a8b5cd4/html5/thumbnails/18.jpg)
Operating Systems: Intro
18
•OS sets up an Interrupt Vector with service routine entry points
–one entry per I/O device or I/O channel
–a dormant context set up for each routine which can be activated on demand
–further interrupts usually switched off during initial interrupt servicing
•Example: Intel x86 interrupt vector entries:
0 : divide error. . .14: page fault32: timer33: keyboard. . .36: serial port 137: parallel port 238: floppy controller. . .46: hard disc
![Page 19: Operating Systems: Intro 1 Operating Systems Concepts and Principles –monolithic and micro kernels –processes and threads »their management and synchronisation](https://reader035.vdocuments.site/reader035/viewer/2022062404/551ae3085503466b6a8b5cd4/html5/thumbnails/19.jpg)
Operating Systems: Intro
19
•An OS can be viewed as an event-driven system
–just reacts to events as they occur
•Interrupts need to be serviced carefully and quickly by the OS
–cost similar to a process switch
–too many interrupts will kill performance
•Alternative to interrupts is Polling
–process (or OS) continually polls I.e. inspects, device status registers awaiting some condition e.g. transfer completed
–wastes time looping until condition occurs
–much simpler to program than using interrupts but inefficient
![Page 20: Operating Systems: Intro 1 Operating Systems Concepts and Principles –monolithic and micro kernels –processes and threads »their management and synchronisation](https://reader035.vdocuments.site/reader035/viewer/2022062404/551ae3085503466b6a8b5cd4/html5/thumbnails/20.jpg)
Operating Systems: Intro
20
Privilege
•Processors run at various levels of privilege
–user-level
»only the types of instruction needed by applications programs
»only access to permitted areas of virtual memory
–supervisor or kernel level
»all types of instruction including I/O instructions
»access to system registers
virtual memory registers
interrupt vectors
»access to all areas of virtual memory
»ability to switch interrupts on and off
–may be intermediate levels on some architectures
–each level may have its own processor registers to speed context switching
![Page 21: Operating Systems: Intro 1 Operating Systems Concepts and Principles –monolithic and micro kernels –processes and threads »their management and synchronisation](https://reader035.vdocuments.site/reader035/viewer/2022062404/551ae3085503466b6a8b5cd4/html5/thumbnails/21.jpg)
Operating Systems: Intro
21
What’s part of an Operating System?
•Process management
•Interrupt handling
•Device drivers
•File system
•Networking
•Applications?
–Web browser?
–Email?
•Windows?
•Command interpreters?
![Page 22: Operating Systems: Intro 1 Operating Systems Concepts and Principles –monolithic and micro kernels –processes and threads »their management and synchronisation](https://reader035.vdocuments.site/reader035/viewer/2022062404/551ae3085503466b6a8b5cd4/html5/thumbnails/22.jpg)
Operating Systems: Intro
22
Kinds of Operating System
•For single-user workstation
•For multiple-user server
–file,compute, mail, web servers etc.
•For mainframe systems
–transaction processing
–database systems
•For real-time systems
–time-critical applications
»industrial process control
–hard rather than soft deadlines
![Page 23: Operating Systems: Intro 1 Operating Systems Concepts and Principles –monolithic and micro kernels –processes and threads »their management and synchronisation](https://reader035.vdocuments.site/reader035/viewer/2022062404/551ae3085503466b6a8b5cd4/html5/thumbnails/23.jpg)
Operating Systems: Intro
23
•All built with the same concurrent multi-process organisation
•Main difference is in process scheduling
–single user system needs only to meet one user’s expectations
»overall efficiency less important
–multiple user system needs to be equitable between users
»efficiency important
–transaction processing system needs to give good response
»database queries
–real-time system may need to pre-allocate processor time to guarantee meeting deadlines
»overall efficiency may need to suffer
![Page 24: Operating Systems: Intro 1 Operating Systems Concepts and Principles –monolithic and micro kernels –processes and threads »their management and synchronisation](https://reader035.vdocuments.site/reader035/viewer/2022062404/551ae3085503466b6a8b5cd4/html5/thumbnails/24.jpg)
Operating Systems: Intro
24
•Only exception to multiple-process organisation is embedded systems
– dedicated single-purpose processors
» multi-media, telecoms
MPEG decoders, GSM phones, portable web browsers
washing machine controllers!
» avionics
FADECs, GPS, FMS
–absolute reliability required
–very conservatively programmed
• System Level Integrated circuits
–usually have a processing core which requires a real-time OS
–often multiprocessors with a general-purpose CPU plus a DSP processor
»ARM + OAK
![Page 25: Operating Systems: Intro 1 Operating Systems Concepts and Principles –monolithic and micro kernels –processes and threads »their management and synchronisation](https://reader035.vdocuments.site/reader035/viewer/2022062404/551ae3085503466b6a8b5cd4/html5/thumbnails/25.jpg)
Operating Systems: Intro
25
Operating System Structure
•How to partition OS functions?
–process management and scheduling, memory management, interrupt handling, device drivers etc.
•Monolithic OS
–each function coded as a separate procedure
–linked into one executable code object
–event-driven core which calls appropriate procedures when required
»driven by interrupts and system calls from processes
–Linux
»modules can be dynamically linked and unlinked as required
![Page 26: Operating Systems: Intro 1 Operating Systems Concepts and Principles –monolithic and micro kernels –processes and threads »their management and synchronisation](https://reader035.vdocuments.site/reader035/viewer/2022062404/551ae3085503466b6a8b5cd4/html5/thumbnails/26.jpg)
Operating Systems: Intro
26
•Micro-kernel OS
–each function coded as a separate process
»system processes
–only the minimum possible function in the core kernel
»virtual memory organising
»interrupt handling
»process dispatching
–appropriate system process activated as soon as possible to deal with all other functions
»system processes will have higher privilege and usually higher priority than user processes
–Windows NT
•Intermediate flavours
–some system processes but not a minimal micro-kernel
![Page 27: Operating Systems: Intro 1 Operating Systems Concepts and Principles –monolithic and micro kernels –processes and threads »their management and synchronisation](https://reader035.vdocuments.site/reader035/viewer/2022062404/551ae3085503466b6a8b5cd4/html5/thumbnails/27.jpg)
Operating Systems: Intro
27
Windows NT Structure
Hardware
![Page 28: Operating Systems: Intro 1 Operating Systems Concepts and Principles –monolithic and micro kernels –processes and threads »their management and synchronisation](https://reader035.vdocuments.site/reader035/viewer/2022062404/551ae3085503466b6a8b5cd4/html5/thumbnails/28.jpg)
Operating Systems: Intro
28
•Advantages and disadvantages
–monolithic:
»faster switching to kernel functions
»simple interfaces between functions i.e. procedure calls
»easier access to data structures shared between functions
»larger memory resident core
»may become too large to maintain easily
–micro-kernel
»better partitioning - should be easier to implement and maintain
»smaller memory resident core
»slower switching to system processes
»inter-system-process communications may be slower