350 likes | 505 Views
operating systems. OS Concepts An Introduction. operating systems. At the end of this module, you should have a basic understanding of what an operating system is, what it does, and what the major components of an operating system are. operating systems. Why should I study
E N D
operating systems OS ConceptsAn Introduction
operating systems At the end of this module, you should have a basic understanding of what an operating system is, what it does, and what the major components of an operating system are.
operating systems Why should I study operating systems?
operating systems Based on a 2007 IT Salary Survey Application ProgrammersSystem Programmers Average Salary $71,020 $79,300 Average Bonus $ 3,410 $ 3,940
operating systems Based on a 2007 IT Salary Survey Application ProgrammersSystem Programmers System Mainframe $74,100 $80,840 Unix/Linux $76,100 $84,100 Windows $71,000 $79,300
operating systems Even as an application programmer, most real commercial applications will require that you • Understand OS design issues and tradeoffs • Performance • Function • Space • Be able to exploit OS capabilities • Multiple Processes • Threads • Synchronization • Communication
operating systems User User User System and Application Programs What Is An Operating System API Language Libraries and System Calls Operating System Kernel CPU
personal computer mainframe system Music players game controllers cell phones
This program has no sense of sharing the system’s resources with other programs. It sees an Abstract Machine that has all of the resources that it needs. Executing Program Operating System Hardware Device Device Device
The Abstract Machine Modern computing systems are multi-user, multi-program systems. The fundamental task of an operating system in this environment is to give each running program a logical, abstract machine that contains all of the resources that it needs to do its job. Input/Output devices Memory CPU General purpose registers Status registers Stack Execution Context
Computer System Organization cpu memory system bus . . . disk controller device controller device controller app app app printer keyboard
Computer System Operation cpu and devices work concurrently cpu memory system bus . . . disk controller device controller device controller printer keyboard
Computer System Operation each device controller is in charge of a particular device type cpu memory system bus . . . disk controller device controller device controller printer keyboard
Computer System Operation cpu memory system bus . . . Each device controller has a local buffer disk controller device controller device controller printer keyboard
Computer System Operation device controllers send interrupts to the cpu to tell it that they have finished an operation the cpu told them to do cpu memory system bus . . . disk controller device controller device controller printer keyboard
Interrupts An interrupt causes control to branch to an interrupt service routine through an interrupt vector. The address of the interrupted instruction is saved. Incoming interrupts are disabled while an interrupt is being processed. A trap is a software generated interrupt. An operating system is interrupt driven.
I/O Processing requesting process Synchronous I/O wait 1. A process starts an I/O operation 2. The requesting process waits until the I/O completes device driver interrupt handler hardware data
I/O Processing requesting process Asynchronous I/O 1. A process starts an I/O operation 2. An acknowledgement is returned 3. The process continues execution 4. The device interrupts the process when the I/O is complete device driver interrupt handler hardware data
Processes A process is defined as a program in execution. It includes * The program itself (program segment) * The program’s data (data segment, stack, heap) * Open files * The execution context
For efficiency, modern operating systems allow many processes to be running concurrently. When one process has to wait for something, typically for an I/O operation to complete, the operating systems schedules another process to run. Many programs can be in memory at the same time. The operating system gives each process a slice of time in which to run.
A thread, or thread of execution, is the set of instructions being executed in a process. In a single thread system each process has exactly one execution engine (the logical machine). In a multi-thread environment, a process may have many execution engines, one for each thread. Thus, each thread has it’s own runtime stack, registers, and state information, but they all share the same address space in memory (program and data), and the same files. In new multi-core machines, each logical engine may run on a real engine. Threads
All of the components required for a program to do it’s job are called resources. * memory * cpu time * devices * files * network connection When a process needs to use a resource, it must ask the operating system for the resource before using it. Once a process asks for a resource, it suspends operation and waits until the resource is available. Resources
Responsibilities of the OS • Create an abstract machine environment for each • running process. • 2. Manage the use of the physical components in • the system, according to the policies of the system’s • administrator or the system designer. • * Device management • * Process and thread management • * Memory Management • * File Management
Device Management The OS manages the allocation, isolation, and sharing of devices. * Terminals * Disk Drives * Printers * Networks * Keyboard * etc
Application Programming Interface Device Drivers Device Independent Part Device Driver Interface Vendor Specific Part Vendor Specific Part Vendor Specific Part
Process & Resource Management Schedules the processor so that each thread/process receives an equitable fraction of the available time, and maintains the execution context for each thread (stack, registers, etc) Allocates resources to processes when they are requested and keeps track of resources when a thread is finished with them. Isolates access to resources or allows sharing of resources as required.
Memory Management Maintains a unique address space in memory for each process. Works with the file and/or device managers to provide virtual memory (address space is larger than physical memory).
File Management Works with the device managers to give applications A logical view of storage (byte stream, indexed data, text files, etc), and manage the flow of information between the actual storage device and the program.
Performance: The OS must be as efficient as possible, maximizing the use of machine resources by applications. There is some overhead involved in providing OS services. If the overhead gets too large, it negates the value of the service. Exclusive Use of Resources: Each process must have the ability to have exclusive use of the system resources that it uses. A process must not be able to use a resource unless the OS has given it permission. Sharing of resources should also be allowed. * Protection Mechanisms * Security Policies Design Issues
Modern computing hardware provides multiple modes of • operation: • User Mode • - Cannot execute all machine instructions (e.g. I/O) • - Can only access memory allocated to the process • Privileged Mode • - Executes any instruction in the repertoire • - Can access protected memory • - Only executes trusted software (The OS kernel) Processor Modes
User Space User Process Kernel . . . fork( ); . . . Trap Instructions trap table Library Code SYS_FORK fork( ) { … trap SYS_FORK( ) . . . } sys_fork( ) { /* system function */ . . . return; } Expensive!
Monolithic Kernels * All OS function resides in the kernel * Fast * difficult to maintain MicroKernels * The trusted OS software is as small as possible - only the essential OS functions * All other code is implemented in user space * Performance the major issue – many kernel calls required OS Organization
The first king is very reclusive and sits in a small castle with high walls and a few top advisors. The king tells the advisors what to do and they go outside of the small (but well defended) castle and issue orders to the knights, merchants and common-folk. The king never leaves his castle and since only his most trusted advisors are allowed in the king is very safe from attack. However, because each advisor has to pass through several guard points it can sometimes take a little while before the king’s orders can go out or news can come in. The second king is much different. He doesn’t really live in a castle so much as it is a large mansion with beautiful grounds. Strongly defended walls encompass the entire city instead of just the castle. This makes the king and the populace very secure from outside attacks. And since this king is very friendly he goes throughout his city meeting and talking with all of his subjects. Any command he, or his many trusted aides, give are instantly obeyed. This makes his city very efficient. However, should any enemy agents manage to penetrate the outer walls, then they can quite easily assassinate the beloved king. In which case order breaks down and the entire city riots.
Libraries Utilities Apps Shell The Unix Kernel OS System Call Interface Device Driver Trap Table Device Driver • Monolithic Kernel Module • Process Mgt • Memory Mgt • File Mgt • Device Mgt Driver Interface