BTEC UNIT 27: Operating systems - Assignment 1
Title - Operating systems development - 1
Issue Date: W/C 30th October 2006
Deadline Date: W/C 13th November
Criteria P1, P2, M1, M2
Task 1
. Identify four main areas of development of operating systems. [P1]
Networking:
Most current operating systems are capable of using the now-universal TCP/IP networking protocols. This means that one system can appear on a network of the other and share resources such as files, printers, and scanners.
Many operating systems also support one or more vendor-specific legacy networking protocols as well, for example, SNA on IBM systems, DECnet on systems from Digital Equipment Corporation, and Microsoft-specific protocols on Windows. Specific protocols for specific tasks may also be supported such as NFS for file access.
Memory management:
Memory management has always been one of the most important and interesting aspects of any operating system for serious developers. It is an aspect that kernel developers ignore. Memory management, in essence, provides a thumbnail impression of any operating system.
Memory management is the act of managing computer memory. In its simpler forms, this involves providing ways to allocate portions of memory to programs at their request, and freeing it for reuse when no longer needed.
Virtual memory systems separate the memory addresses used by a process from actual physical addresses, allowing separation of processes and increasing the effectively available amount of RAM using disk swapping. The quality of the virtual memory manager can have a big impact on overall system performance.
Garbage collection is the automated allocation, and deal location of computer memory resources for a program. This is generally implemented at the programming language level and is in opposition to manual memory management, the explicit allocation and deal location of computer memory resources.
Resource management:
The OS controls all of the resources on the computer, for example:
* The amount of processor time that will be spent on certain tasks
* The amount of memory allocated to programs that are currently running
* Access to secondary storage devices, such as hard disks
* Access to peripherals, such as printers.
File management
* The OS also controls the location of all of the files stored on a computer.
* It uses directories (folders) to store files in and the files are identified by the name given them by the user and a suffix that indicates the file type.
* For example, you might set up a folder called coursework and then store coursework.doc inside it.
* The user sees this as folders and is able to create, edit and delete folders into which the work is stored and rename files.
* The OS stores folders as directories using a pathname.
* The pathnames are stored on the drive that contains them (e.g. C drive is the hard disk or D drive is the CD disk).
Multitasking:
Multitasking is a method by which multiple tasks, also known as processes, share common processing resources such as a CPU. In the case of a computer with a single CPU, only one task is said to be running at any point in time, meaning that the CPU is actively executing instructions for that task. Multitasking solves the problem by scheduling which task may be the one running at any given time, and when another waiting task gets a turn. The act of reassigning a CPU from one task to another one is called a context switch. When context switches occur frequently enough the illusion of parallelism is achieved. Even on computers with more than one CPU (called multiprocessor machines), multitasking allows many more tasks to be run than there are CPUs.
Scheduling:
Scheduling is a key concept in computer multitasking and multiprocessing operating system design, and in real-time operating system design. It refers to the way processes are assigned priorities in a priority queue. This assignment is carried out by software known as a scheduler.
In general-purpose operating systems, the goal of the scheduler is to balance processor loads, and prevent any one process from either monopolizing the processor or being starved for resources. In operating systems designed from the ground up for critical application use, such as Solaris, AIX or z/OS, schedulers include "defensive" features. If a process (by design or accident) should attempt to aggressively grab all available processor resources, the system often reacts by slowing down to the point of being perceived as "locked".
2. Identify the main purposes of an operating system, [P2]
3. Explain, using appropriate examples of operating systems, how these purposes serve the requirements of a computer system [M1]
The most important program that runs on a computer. Every general-purpose computer must have an operating system to run other programs. Operating systems perform basic tasks, such as recognizing input from the keyboard, sending output to the display screen, keeping track of files and directories on the disk, and controlling peripheral devices such as disk drives and printers.
For large systems, the operating system has even greater responsibilities and powers. It is like a traffic cop -- it makes sure those different programs and users running at the same time do not interfere with each other. The operating system is also responsible for security, ensuring that unauthorized users do not access the system.
Operating systems can be classified as follows:
* Multi-user : Allows two or more users to run programs at the same time. Some operating systems permit hundreds or even thousands of concurrent users.
* Multiprocessing : Supports running a program on more than one CPU.
* Multitasking : Allows more than one program to run concurrently.
* Multithreading : Allows different parts of a single program to run concurrently.
* Real time: Responds to input instantly. General-purpose operating systems, such as DOS and UNIX, are not real-time.
Operating systems provide a software platform on top of which other programs, called application programs, can run. The application programs must be written to run on top of a particular operating system. Your choice of operating system, therefore, determines to a great extent the applications you can run. For PCs, ...
This is a preview of the whole essay
* Multitasking : Allows more than one program to run concurrently.
* Multithreading : Allows different parts of a single program to run concurrently.
* Real time: Responds to input instantly. General-purpose operating systems, such as DOS and UNIX, are not real-time.
Operating systems provide a software platform on top of which other programs, called application programs, can run. The application programs must be written to run on top of a particular operating system. Your choice of operating system, therefore, determines to a great extent the applications you can run. For PCs, the most popular operating systems are DOS, OS/2, and Windows, but others are available, such as Linux.
As a user, you normally interact with the operating system through a set of commands. For example, the DOS operating system contains commands such as COPY and RENAME for copying files and changing the names of files, respectively. The commands are accepted and executed by a part of the operating system called the command processor or command line interpreter. Graphical user interfaces allow you to enter commands by pointing and clicking at objects that appear on the screen.
At the simplest level, an operating system does two things:
. It manages the hardware and software resources of the system. In a desktop computer, these resources include such things as the processor, memory, disk space, etc. (On a cell phone, they include the keypad, the screen, the address book, the phone dialer, the battery and the network connection.)
2. It provides a stable, consistent way for applications to deal with the hardware without having to know all the details of the hardware.
The first task, managing the hardware and software resources, is very important, as various programs and input methods compete for the attention of the central processing unit (CPU) and demand memory, storage and input/output (I/O) bandwidth for their own purposes. In this capacity, the operating system plays the role of the good parent, making sure that each application gets the necessary resources while playing nicely with all the other applications, as well as husbanding the limited capacity of the system to the greatest good of all the users and applications.
The second task, providing a consistent application interface, is especially important if there is to be more than one of a particular type of computer using the operating system, or if the hardware making up the computer is ever open to change. A consistent application program interface (API) allows a software developer to write an application on one computer and have a high level of confidence that it will run on another computer of the same type, even if the amount of memory or the quantity of storage is different on the two machines.
Even if a particular computer is unique, an operating system can ensure that applications continue to run when hardware upgrades and updates occur. This is because the operating system and not the application is charged with managing the hardware and the distribution of its resources. One of the challenges facing developers is keeping their operating systems flexible enough to run hardware from the thousands of vendors manufacturing computer equipment. Today's systems can accommodate thousands of different printers, disk drives and special peripherals in any possible combination.
Task 2
4. Describe the four main management functions of an operating system, [P4]
Process or Thread Management
•The operating system manages many kinds of activities.
• Each of these activities is encapsulated in a process.
•A process is not a program.
•A process is only ONE instant of a program in execution.
The five major activities of an operating system in regard to process management are :
•Creation and deletion of user and system processes.
•Suspension and resumption of processes.
•A mechanism for process synchronization.
•A mechanism for process communication.
•A mechanism for deadlock handling.
Main Memory Management
Primary-Memory or Main-Memory is a large array of words or bytes. Each word or byte has its own address. Main-memory provides storage that can be access directly by the CPU.
The major activities of an operating system in regard to memory-management are:
•Keep track of which part of memory are currently being used and by whom.
•Decide which process are loaded into memory when memory space becomes available.
•Allocate and de-allocate memory space as needed.
File System Management
A file is a collection of related information defined by its creator.
•Computer can store files on the disk (secondary storage), which provide long term storage.
•Some examples of storage media are magnetic tape, magnetic disk and optical disk.
•Each of these media has its own properties like speed, capacity, data transfer rate and access methods.
The five main major activities of an operating system in regard to file management are :
•The creation and deletion of files.
•The creation and deletion of directions.
•The support of primitives for manipulating files and directions.
•The mapping of files onto secondary storage.
•The back up of files on stable storage media.
Input/Output Functions:
•Programmed I/O
•Interrupt Driven I/O
•Direct Memory access
Programmed Input/Output:
The processor issues an I/O command on behalf of a process to an I/O module; that process then busy-waits for the operation to be complete before proceeding.
Interrupt-driven I/O:
The processor issues an I/O command on behalf of a process, continues to execute subsequent instructions, and is interrupted by the I/O module when the latter has completed its work. The subsequent instructions may be in the same process if it is not necessary for that process to wait for the completion of the I/O. Otherwise, the process is suspended pending the interrupt, and other work is performed.
Direct memory access (DMA):
A DMA module controls the exchange of data between main memory and an I/O module. The processor sends a request for the transfer of a block of data to the DMA module and is interrupted only after the entire block has been transferred.
I/O Function
5. Describe, using appropriate examples, how these management functions enable the operation of a modern computer system [M2 ]
Main Management Functions of an operating system:
Process or Thread Management
The operating system manages many kinds of activities ranging from user programs to system programs like printer spooler, name servers, file server etc. Each of these activities is encapsulated in a process. A process includes the complete execution context (code, data, PC, registers, OS resources in use etc.).
It is important to note that a process is not a program. A process is only ONE instant of a program in execution. There are many processes can be running the same program. The five major activities of an operating system in regard to process management are
* Creation and deletion of user and system processes.
* Suspension and resumption of processes.
* A mechanism for process synchronization.
* A mechanism for process communication.
* A mechanism for deadlock handling.
•The operating system manages many kinds of activities.
• Each of these activities is encapsulated in a process.
•A process is not a program.
•A process is only ONE instant of a program in execution.
Main-memory Management
Primary-Memory or Main-Memory is a large array of words or bytes. Each word or byte has its own address. Main-memory provides storage that can be access directly by the CPU. That is to say for a program to be executed, it must in the main memory.
The major activities of an operating in regard to memory-management are:
* Keep track of which part of memory are currently being used and by whom.
* Decide which process are loaded into memory when memory space becomes available.
* Allocate and deallocate memory space as needed.
File and Disk Management
A file is a collected of related information defined by its creator. Computer can store files on the disk (secondary storage), which provide long term storage. Some examples of storage media are magnetic tape, magnetic disk and optical disk. Each of these media has its own properties like speed, capacity, data transfer rate and access methods.
A file systems normally organized into directories to ease their use. These directories may contain files and other directions.
The five main major activities of an operating system in regard to file management are
. The creation and deletion of files.
2. The creation and deletion of directions.
3. The support of primitives for manipulating files and directions.
4. The mapping of files onto secondary storage.
5. The back up of files on stable storage media.
Input/Output system management
I/O subsystem hides the peculiarities of specific hardware devices from the user. Only the device driver knows the peculiarities of the specific device to whom it is assigned
5. Describe, using appropriate examples, how these management functions enable the operation of a modern computer system [M2 ]
Processor Management
The heart of managing the processor comes down to two related issues:
* Ensuring that each process and application receives enough of the processor's time to function properly.
* Using as many processor cycles for real work as is possible.
The basic unit of software that the operating system deals with in scheduling the work done by the processor is either a process or a thread, depending on the operating system.
It's tempting to think of a process as an application, but that gives an incomplete picture of how processes relate to the operating system and hardware. The application you see (word processor or spreadsheet or game) is, indeed, a process, but that application may cause several other processes to begin, for tasks like communications with other devices or other computers. There are also numerous processes that run without giving you direct evidence that they ever exist. For example, Windows XP and UNIX can have dozens of background processes running to handle the network, memory management, disk management, virus checking and so on.
A process, then, is software that performs some action and can be controlled -- by a user, by other applications or by the operating system.
It is processes, rather than applications, that the operating system controls and schedules for execution by the CPU. In a single-tasking system, the schedule is straightforward. The operating system allows the application to begin running, suspending the execution only long enough to deal with interrupts and user input.
Interrupts are special signals sent by hardware or software to the CPU. It's as if some part of the computer suddenly raised its hand to ask for the CPU's attention in a lively meeting. Sometimes the operating system will schedule the priority of processes so that interrupts are masked -- that is, the operating system will ignore the interrupts from some sources so that a particular job can be finished as quickly as possible. There are some interrupts (such as those from error conditions or problems with memory) that are so important that they can't be ignored. These non-maskable interrupts (NMIs) must be dealt with immediately, regardless of the other tasks at hand.
While interrupts add some complication to the execution of processes in a single-tasking system, the job of the operating system becomes much more complicated in a multi-tasking system. Now, the operating system must arrange the execution of applications so that you believe that there are several things happening at once. This is complicated because the CPU can only do one thing at a time. In order to give the appearance of lots of things happening at the same time, the operating system has to switch between different processes thousands of times a second. Here's how it happens:
* A process occupies a certain amount of RAM. It also makes use of registers, stacks and queues within the CPU and operating-system memory space.
* When two processes are multi-tasking, the operating system allots a certain number of CPU execution cycles to one program.
* After that number of cycles, the operating system makes copies of all the registers, stacks and queues used by the processes, and notes the point at which the process paused in its execution.
* It then loads all the registers, stacks and queues used by the second process and allows it a certain number of CPU cycles.
* When those are complete, it makes copies of all the registers, stacks and queues used by the second program, and loads the first program.
All of the information needed to keep track of a process when switching is kept in a data package called a process control block. The process control block typically contains:
* An ID number that identifies the process
* Pointers to the locations in the program and its data where processing last occurred
* Register contents
* States of various flags and switches
* Pointers to the upper and lower bounds of the memory required for the process
* A list of files opened by the process
* The priority of the process
* The status of all I/O devices needed by the process
Each process has a status associated with it. Many processes consume no CPU time until they get some sort of input. For example, a process might be waiting on a keystroke from the user. While it is waiting for the keystroke, it uses no CPU time. While it is waiting, it is "suspended". When the keystroke arrives, the OS changes its status. When the status of the process changes, from pending to active, for example, or from suspended to running, the information in the process control block must be used like the data in any other program to direct execution of the task-switching portion of the operating system.
This process swapping happens without direct user interference, and each process gets enough CPU cycles to accomplish its task in a reasonable amount of time. Trouble can come, though, if the user tries to have too many processes functioning at the same time. The operating system itself requires some CPU cycles to perform the saving and swapping of all the registers, queues and stacks of the application processes. If enough processes are started, and if the operating system hasn't been carefully designed, the system can begin to use the vast majority of its available CPU cycles to swap between processes rather than run processes. When this happens, it's called thrashing, and it usually requires some sort of direct user intervention to stop processes and bring order back to the system.
One way that operating-system designers reduce the chance of thrashing is by reducing the need for new processes to perform various tasks. Some operating systems allow for a "process-lite," called a thread, that can deal with all the CPU-intensive work of a normal process, but generally does not deal with the various types of I/O and does not establish structures requiring the extensive process control block of a regular process. A process may start many threads or other processes, but a thread cannot start a process.
So far, all the scheduling we've discussed has concerned a single CPU. In a system with two or more CPUs, the operating system must divide the workload among the CPUs, trying to balance the demands of the required processes with the available cycles on the different CPUs. Asymmetric operating systems use one CPU for their own needs and divide application processes among the remaining CPUs. Symmetric operating systems divide themselves among the various CPUs, balancing demand versus CPU availability even when the operating system itself is all that's running.
Even if the operating system is the only software with execution needs, the CPU is not the only resource to be scheduled. Memory management is the next crucial step in making sure that all processes run smoothly.
Memory Storage and Management
When an operating system manages the computer's memory, there are two broad tasks to be accomplished:
. Each process must have enough memory in which to execute, and it can neither run into the memory space of another process nor be run into by another process.
2. The different types of memory in the system must be used properly so that each process can run most effectively.
The first task requires the operating system to set up memory boundaries for types of software and for individual applications.
As an example, let's look at an imaginary small system with 1 megabyte (1,000 kilobytes) of RAM. During the boot process, the operating system of our imaginary computer is designed to go to the top of available memory and then "back up" far enough to meet the needs of the operating system itself. Let's say that the operating system needs 300 kilobytes to run. Now, the operating system goes to the bottom of the pool of RAM and starts building up with the various driver software required to control the hardware subsystems of the computer. In our imaginary computer, the drivers take up 200 kilobytes. So after getting the operating system completely loaded, there are 500 kilobytes remaining for application processes.
When applications begin to be loaded into memory, they are loaded in block sizes determined by the operating system. If the block size is 2 kilobytes, then every process that is loaded will be given a chunk of memory that is a multiple of 2 kilobytes in size. Applications will be loaded in these fixed block sizes, with the blocks starting and ending on boundaries established by words of 4 or 8 bytes. These blocks and boundaries help to ensure that applications won't be loaded on top of one another's space by a poorly calculated bit or two. With that ensured, the larger question is what to do when the 500-kilobyte application space is filled.
In most computers, it's possible to add memory beyond the original capacity. For example, you might expand RAM from 1 to 2 megabytes. This works fine, but tends to be relatively expensive. It also ignores a fundamental fact of computing -- most of the information that an application stores in memory is not being used at any given moment. A processor can only access memory one location at a time, so the vast majority of RAM is unused at any moment. Since disk space is cheap compared to RAM, then moving information in RAM to hard disk can greatly expand RAM space at no cost. This technique is called virtual memory management.
Disk storage is only one of the memory types that must be managed by the operating system, and is the slowest. Ranked in order of speed, the types of memory in a computer system are:
* High-speed cache - This is fast, relatively small amounts of memory that are available to the CPU through the fastest connections. Cache controllers predict which pieces of data the CPU will need next and pull it from main memory into high-speed cache to speed up system performance.
* Main memory - This is the RAM that you see measured in megabytes when you buy a computer.
* Secondary memory - This is most often some sort of rotating magnetic storage that keeps applications and data available to be used, and serves as virtual RAM under the control of the operating system.
The operating system must balance the needs of the various processes with the availability of the different types of memory, moving data in blocks (called pages) between available memories as the schedule of processes dictates.
Device Management
The path between the operating system and virtually all hardware not on the computer's motherboard goes through a special program called a driver. Much of a driver's function is to be the translator between the electrical signals of the hardware subsystems and the high-level programming languages of the operating system and application programs. Drivers take data that the operating system has defined as a file and translate them into streams of bits placed in specific locations on storage devices, or a series of laser pulses in a printer.
Because there are such wide differences in the hardware controlled through drivers, there are differences in the way that the driver programs function, but most are run when the device is required, and function much the same as any other process. The operating system will frequently assign high-priority blocks to drivers so that the hardware resource can be released and readied for further use as quickly as possible.
One reason that drivers are separate from the operating system is so that new functions can be added to the driver -- and thus to the hardware subsystems -- without requiring the operating system itself to be modified, recompiled and redistributed. Through the development of new hardware device drivers, development often performed or paid for by the manufacturer of the subsystems rather than the publisher of the operating system, input/output capabilities of the overall system can be greatly enhanced.
Managing input and output is largely a matter of managing queues and buffers, special storage facilities that take a stream of bits from a device, perhaps a keyboard or a serial port, hold those bits, and release them to the CPU at a rate slow enough for the CPU to cope with. This function is especially important when a number of processes are running and taking up processor time. The operating system will instruct a buffer to continue taking input from the device, but to stop sending data to the CPU while the process using the input is suspended. Then, when the process needing input is made active once again, the operating system will command the buffer to send data. This process allows a keyboard or a modem to deal with external users or computers at a high speed even though there are times when the CPU can't use input from those sources.
Managing all the resources of the computer system is a large part of the operating system's function and, in the case of real-time operating systems, may be virtually all the functionality required. For other operating systems, though, providing a relatively simple, consistent way for applications and humans to use the power of the hardware is a crucial part of their reason for existing.
Bibliography
http://computer.howstuffworks.com/operating-system2.htm
http://en.wikipedia.org/wiki/Computer_multitasking
Class Notes
D:\Unit 27 Operating Sytems\Assignment1\Operating system development.doc\Manmeet Singh (Kaur)