An operating system is an interface between the user and the architecture.
OS as juggler: providing the illusion of a dedicated machine with infinite memory and CPU.
OS as a government: protecting users from each other, allocating resources efficiently and fairly, and providing secure and safe communication.
OS as complex system: keeping OS design and implementation as simple as possible is the key to getting the OS to work
What is an Operating System?
v Any code that runs with the hardware kernel bit set
Ø An abstract virtual machine
Ø A set of abstractions that simplify application design
· Files instead of “bytes on a disk”
v Files instead of bytes on a disk Core OS services, written by “pros”
Ø Processes, process scheduling
Ø Address spaces
Ø Device control
Ø ~30% of Linux source code. Basis of stability and security
v Device drivers written by “whoever”
Ø Software run in kernel to manages a particular vendors hardware
· E.g. Homer Simpson doll with USB
Ø ~70% of Linux source code
Ø OS is extensible
Ø Drivers are the biggest source of OS instability
v For any OS area (CPU scheduling, file systems, memory management), begin by asking two questions
Ø that's the hardware interface? (The Physical Reality)
Ø What is the application interface? (The Nicer Inter face for programmer productivity)
it is hard to pin down what an operating system is other than saying it is the software that runs in kernel mode-and even that is not always true.part of the problem is that operating system performs two basically unrelated functions: providing application programmers a clean abstract set of resources instead of the messy hardware ones and managing these hardware resources. depending on who is doing the talking, you might hear mostly about one function or the other. let us now look at both.
it is hard to pin down what an operating system is other than saying it is the software that runs in kernel mode-and even that is not always true.part of the problem is that operating system performs two basically unrelated functions: providing application programmers a clean abstract set of resources instead of the messy hardware ones and managing these hardware resources. depending on who is doing the talking, you might hear mostly about one function or the other. let us now look at both.
Operating system as an Extended Machine
The architecture (instruction set, memory organization, I/O, and bus structure ) of most computers at the machine language level is primitive and awkward to programs, especially for input/output.to make this point more consider how floppy disk I/O is done using the NEC PD765 has compatible controller chip used on most Intel-based personal computers. we use the floppy disk as an example, because, although it is obsolete, it is much simpler than a modern hard disk. the PD765 has 16 commands, each specified by loading and between 1 and 9 bytes into a device register. these commands are for reading and writing data, moving the disk arm, and formatting tracks, as well as initializing, sensing, resetting and recalibrating the controller and the drives.
The most basic commands are read and write, each of which requires 13 parameters, packed into 9bytes. these parameters specify such items as the address of the disk block to be read, the numbers of sectors per track, the recording mode used on the physical medium, the inter-sector gap spacing, and what to do with a deleted-data-address-mask.if you do not understand this mumbo jumbo, do not worry; that is precisely the point-it is rather esoteric. when the operation is completed, the controller chip returns 23 status and error fields packed into 7 bytes. as if this were not enough, the floppy disk programmers must also be constantly aware of whether the motor is on or off. if the motor is off, it must be turned on before data can be read or written. the motor can not be left on long, however, or the floppy disk will wear out. the programmers are thus forced to deal with the trade-off between long start-up delays versus wearing out a floppy disk.
Without going into the real details, it should be clear that the average programmer probably does not want to get too intimately involved with the programming of floppy disks (or hard disks, which are worse). Instead, what the programmer wants is a simple, high-level abstraction to deal with. In the case of
disks, a typical abstraction would be that the disk contains a collection of named files. Each file can be opened for reading or writing, then read or written, and finally closed. Details such as whether or not recording should use modified frequency modulation and what the current state of the motor is should not appear in
the abstraction presented to the application programmer.
Abstraction is the key to managing complexity. Good abstractions turn a
nearly impossible task into two manageable ones. The first one of these is defining and implementing the abstractions. The second one is using these abstractions
to solve the problem at hand. One abstraction that almost every computer user
understands is the file. It is a useful piece of information, such as a digital photo, saved an email message, or Web page. Dealing with photos, e-mails, and Web pages
are easier than the details of disks, such as the floppy disk described above. The job
of the operating system is to create good abstractions and then implement and
manage the abstract objects thus created
disks, a typical abstraction would be that the disk contains a collection of named files. Each file can be opened for reading or writing, then read or written, and finally closed. Details such as whether or not recording should use modified frequency modulation and what the current state of the motor is should not appear in
the abstraction presented to the application programmer.
Abstraction is the key to managing complexity. Good abstractions turn a
nearly impossible task into two manageable ones. The first one of these is defining and implementing the abstractions. The second one is using these abstractions
to solve the problem at hand. One abstraction that almost every computer user
understands is the file. It is a useful piece of information, such as a digital photo, saved an email message, or Web page. Dealing with photos, e-mails, and Web pages
are easier than the details of disks, such as the floppy disk described above. The job
of the operating system is to create good abstractions and then implement and
manage the abstract objects thus created
Operating System as a Resource Manager
The concept of an operating system as primarily providing abstractions to an application program is a top-down view. an alternative bottom-up, view holds that the operating system is there to manage all the pieces of a complex system. modern computers consist of processors, memories, timers, disks, mice, network interfaces, printers, and a wide verity of other devices. in the alternative view, the job of the operating system is to provide for an orderly and controlled allocation of the processors, memories, and I/O devices among the various programs competing for them.
Modern operating systems allow multiple programs to run at the same time.Imagine what would happen if three programs running on some computer all tried to print their output simultaneously on the same printer. The first few lines of printout might be from a program I, the next few from program 2, then some from program 3, and so forth. The result would be chaos. The operating system can bring order to the potential chaos by buffering all the output destined for the printer on the disk. When one program is finished, the operating system can then copy its output from the disk file where it has been stored for the printer, while at the same time the other program can continue generating more output, oblivious to the fact that the output is not really going to the printer (yet).
When a computer (or network) has multiple users, the need for managing and protecting the memory, I/O devices, and other resources is even greater, since the users might otherwise interfere with one another. In addition, users often need to share not only hardware but information (files, databases, etc.) as well. In short, this view of the operating system holds that its primary task is to keep track of which programs are using which resource, to grant resource requests, to account for usage, and to mediate conflicting requests from different programs and users.
Resource management includes multiplexing (sharing) resources in two different ways: in time and in space. When a resource is a time multiplexed, different programs or users take turns using it. First one of them gets to use the resource, then another, and so on. For example, with only one CPU and multiple programs that want to run on it, the operating system first allocates the CPU to one program, then, after it has run long enough, another one gets to use the CPU, then another, and then eventually the first one again. Determining how the resource is time multiplexed—who goes next and for how long—is the task of the operating system.
Another example of time multiplexing is sharing the printer. When multiple print jobs are queued up for printing on a single printer, a decision has to be made about which one is to be printed next.
The other kind of multiplexing is space multiplexing. Instead of the customers taking turns, each one gets part of the resource. For example, main memory is normally divided up among several running programs so each one can be resident at the same time (for example, in order to take turns using the CPU). Assuming there is enough memory to hold multiple programs, it is more efficient to hold several programs in.memory at once rather than give one of them all of it, especially if it only needs a small fraction of the total. Of course, this raises issues of fairness, protection, and so on, and it is up to the operating system to solve them. Another resource that is space multiplexed is the (hard) disk. In many systems, a single disk can hold files from many users at the same time. Allocating disk space and keeping track of who is using which disk blocks is a typical operating system resource management task.
Another example of time multiplexing is sharing the printer. When multiple print jobs are queued up for printing on a single printer, a decision has to be made about which one is to be printed next.
History of Operating Systems
Operating systems have been evolving through the years. In the following sections, we will briefly look at a few of the highlights. Since operating systems have historically been closely tied to the architecture of the computers on which they run, we will look at successive generations of computers to see what their operating systems were like. This mapping of operating system generations to computer generations is crude, but it does provide some structure where there would otherwise be none.
The progression given below is largely chronological, but it has been a bumpy ride. Each development did not wait until the previous one nicely finished before getting started. There was a lot of overlap, not to mention many false starts and dead ends. Take this as a guide, not as the last word.
The first true digital computer was designed by the English mathematician Charles Babbage (1792-1871). Although Babbage spent most of his life and fortune trying to build his "analytical engine," he never got it working properly because it was purely mechanical, and the technology of his day could not produce the required wheels, gears, and cogs to the high precision that he needed. Needless to say, the analytical engine did not have an operating system.
As an interesting historical aside, Babbage realized that he would need software for his analytical engine, so he hired a young woman named Ada Lovelace, who was the daughter of the famed British poet Lord Byron, as the world's first programmer. The programming language Ada® is named after her.
Operating System Functions
The first true digital computer was designed by the English mathematician Charles Babbage (1792-1871). Although Babbage spent most of his life and fortune trying to build his "analytical engine," he never got it working properly because it was purely mechanical, and the technology of his day could not produce the required wheels, gears, and cogs to the high precision that he needed. Needless to say, the analytical engine did not have an operating system.
As an interesting historical aside, Babbage realized that he would need software for his analytical engine, so he hired a young woman named Ada Lovelace, who was the daughter of the famed British poet Lord Byron, as the world's first programmer. The programming language Ada® is named after her.
Operating System Functions
v Service provider
Ø Provide standard facilities
· File system
· Standard Libraries
· Window system
v Coordinator: three aspects
Ø Protection: prevent jobs from interfering with each other
Ø Communication: enable jobs to interact with each other
Ø Resource management: facilitate sharing of resources across jobs.
v Operating systems are everywhere
Ø )Single-function devices (embedded controllers, Nintendo, …)
· OS provides a collection of standard services
· Sometimes OS/middleware distinction is blurry
Ø Multi-function/application devices (workstations and servers)
· OS manages application interactions
Why do we need operating systems?
v Convenience
Ø Provide a high-level abstraction of physical resources
· Make hardware usable by getting rid of warts & specifics
Ø Enable the construction of more complex software systems
Ø Enable portable code.
· MS-DOS version 1 boots on the latest 3+ GHz Pentium.
· Would games that ran on MS-DOSv1 work well today?
v Efficiency
Ø Share limited or expensive physical resources.
Ø Provide protection.
Computer Architecture & Processes
v CPU the processor that performs the actual computation
v I/O devices -terminal, disks, video board, printer, etc.
v Memory -RAM containing data and programs used by the CPU
v System bus -the communication medium between the CPU, memory, and peripherals
Interrupts -Moving from Kernel to User Mode
User processes may not
v address I/O directly
v use instructions that manipulate OS memory (e.g., page tables)
v set the mode bits that determine user or kernel mode
v disable and enable interrupts halt the machine
but in kernel mode, the OS does all these things
v a status bit in a protected processor register indicates the mode
v Protected instructions can only be executed in kernel mode.
v On interrupts (e.g., time slice) or system calls
History of Operating Systems: Phases
§ Phase 1: Hardware is expensive, humans are cheap
Ø User at console: single-user systems
Ø Batching systems
Ø Multi-programming
§ Phase 2: Hardware is cheap, humans are expensive
Ø Time sharing: Users use cheap terminals and share servers
§ Phase 3: Hardware is very cheap, humans are very expensive
Ø Personal computing: One system per user
Ø Distributed computing: lots of systems per user
§ Phase 4: Ubiquitous computing/Cloud computing
Ø Cell phone, mp3 player, DVD player, TIVO, PDA, iPhone, e Reader
Ø Software as a service, Amazon’s elastic compute cloud
Operating Systems for PCs
§ Personal computing systems
Ø Single user
Ø Utilization is no longer a concern
Ø Emphasis is on user interface and API
Ø Many services & features not present
§ Evolution
Ø Initially: OS as a simple service provider (simple libraries)
Ø Now: Multi-application systems with support for coordination and communication
Ø Growing security issues (e.g., online commerce, medical records)
Distributed Operating Systems
o Typically support distributed services
Ø Sharing of data and coordination across multiple systems
o Possibly employ multiple processors
Ø Loosely coupled v. tightly coupled systems
o High availability & reliability requirements
Ø Amazon, CNN
What is cloud computing?
v Cloud computing where dynamically scalable and often virtualized resources are provided as a service!) over the Internet (thanks, Wikipedia!)
v Infrastructure as a service (IaaS)
Ø Amazon’s EC2 (elastic compute cloud)
v Platform as a service (PaaS)
Ø Google Gears
Ø Microsoft Azure
v Software as a service (SaaS)
Ø Gmail
Ø Facebook
Ø Flickr
No comments:
Post a Comment