You are on page 1of 8

Assignment #01

[Q01.] a.) An operating System tells the computer how to use its own components. An operating system
is essential for any computer, because it acts as an interface between the hardware, application programs and the user.

b.)
1. Computer Hardware provides basic computing resources (CPU, memory, I/O devices). 2. Operating System controls and coordinates the use of the hardware among the various application programs for the various users. 3. System Programs provide functionality to the computer.

ROM programs Operating system Device drivers

4. Application Programs define the ways in which the system resources are used to solve

the computing problems of the users (compilers, database systems, video games, business programs). 5. User people, machines, other computers

c.)
(i) Main Tasks of Kernel 1. The kernel takes responsibility for deciding at any time which of the many running programs should be allocated to the processor or processors (each of which can usually run only one program at a time) The main task of a kernel is to allow the execution of applications and support them with features such as hardware abstractions. A process defines which memory portions the application can access. Kernel process management must take into account the hardware built-in equipment for memory protection. To run an application, a kernel typically sets up an address space for the application, loads the file containing the application's code into memory (perhaps via demand paging), sets up a stack for the program and branches to a given location inside the program, thus starting its execution. 2. The kernel is responsible for deciding which memory each process can use, and determining what to do when not enough is available. The kernel has full access to the system's memory and must allow processes to safely access this memory as they require it. Often the first step in doing this is virtual addressing, usually achieved by paging and/or segmentation. Virtual addressing allows the kernel to make a given physical

1|Page

Assignment #01

address appear to be another address, the virtual address. Virtual address spaces may be different for different processes; the memory that one process accesses at a particular (virtual) address may be different memory from what another process accesses at the same address. This allows every program to behave as if it is the only one (apart from the kernel) running and thus prevents applications from crashing each other. 3. The kernel allocates requests from applications to perform I/O to an appropriate device (or subsection of a device, in the case of files on a disk or windows on a display) and provides convenient methods for using the device (typically abstracted to the point where the application does not need to know implementation details of the device). To perform useful functions, processes need access to the peripherals connected to the computer, which are controlled by the kernel through device drivers. For example, to show the user something on the screen, an application would make a request to the kernel, which would forward the request to its display driver, which is then responsible for actually plotting the character/pixel. A kernel must maintain a list of available devices. This list may be known in advance (e.g. on an embedded system where the kernel will be rewritten if the available hardware changes), configured by the user (typical on older PCs and on systems that are not designed for personal use) or detected by the operating system at run time (normally called plug and play). (ii) The Steps That a Typical Boot Sequence Involves

1. The user switches on the system. 2. The power supply does a self-check and then sends a Power-Good Signal to the CPU. 3. The CPU starts executing code stored in ROM on the motherboard at address FFFF0. 4. The routines in ROM test the central hardware, search for the video ROM, perform a checksum on the video ROM and execute the routines in video ROM. 5. The routines in the motherboard ROM then continue searching for any other ROM, checksum and execute these routines. 6. If the system is performing a cold start, the POST (power-on-self-test) is executed. The system then searches for a boot device. If there are any fatal errors, the boot process stops. 7. The BIOS looks for the video card. In particular, it looks for the video cards built in BIOS program and runs it. These BIOS is normally found at location C000h in memory. The system BIOS executes the video card BIOS, which initializes the video card. Most modern cards will display information on the screen about the video card. 8. The BIOS then looks for other devices' ROMs to see if any of them have BIOS. Normally, the IDE/ATA hard disk BIOS will be found at C8000h and executed. If any other device BIOS are found, they are executed as well. 9. The BIOS displays its startup screen.
2|Page

Assignment #01

10. The BIOS does more tests on the system, including the memory count-up test which you see on the screen. The BIOS will generally display a text error message on the screen if it encounters an error at this point; these error messages and their explanations can be found in this part of the Troubleshooting Expert. 11. The BIOS performs a "system inventory" of sorts, doing more tests to determine what sort of hardware is in the system. Modern BIOS have many automatic settings and will determine memory timing (for example) based on what kind of memory it finds. Many BIOS can also dynamically set hard drive parameters and access modes, and will determine these at roughly this time. Some will display a message on the screen for each drive they detect and configure this way. The BIOS will also now search for and label logical devices (COM and LPT ports). 12. If the BIOS support the Plug and Play standard, it will detect and configure Plug and Play devices at this time and display a message on the screen for each one it finds. See here for more details on how PnP detects devices and assigns resources. 13. The BIOS will display a summary screen about your system's configuration. Checking this page of data can be helpful in diagnosing setup problems, although it can be hard to see because sometimes it flashes on the screen very quickly before scrolling off the top. 14. The BIOS begins the search for a drive to boot from. Most modern BIOS contain a setting that controls if the system should first try to boot from the floppy disk (A :) or first try the hard disk (C :). Some BIOS will even let you boot from your CD-ROM drive or other devices, depending on the boot sequence BIOS setting. 15. Having identified its target boot drive, the BIOS looks for boot information to start the operating system boot process. If it is searching a hard disk, it looks for a master boot record at cylinder 0, head 0, sector 1 (the first sector on the disk); if it is searching a floppy disk, it looks at the same address on the floppy disk for a volume boot sector. 16. If it finds what it is looking for, the BIOS start the process of booting the operating system, using the information in the boot sector. At this point, the code in the boot sector takes over from the BIOS. The DOS boot process is described in detail here. If the first device that the system tries (floppy, hard disk, etc.) is not found, the BIOS will then try the next device in the boot sequence, and continue until it finds a bootable device. 17. If no boot device at all can be found, the system will normally display an error message and then freeze up the system. What the error message is depends entirely on the BIOS, and can be anything from the rather clear "No boot device available" to the very cryptic "NO ROM BASIC - SYSTEM HALTED". This will also happen if you have a bootable hard disk partition but forget to set it active.

[Q02.]

3|Page

Assignment #01

d.) Process of Instruction Execution


The basic function performed by a computer is program execution. The program (to be executed) consists of a set of instructions stored in memory. Instruction processing consists of two steps.

Fetch Cycle: Processor reads (fetches) instruction from memory one at a time is called "fetch cycle". Program Counter (PC) holds address of next instruction to fetch Processor fetches instruction from memory location pointed to by PC Increment PC Unless told otherwise Instruction loaded into Instruction Register (IR) Processor interprets instruction and performs required actions

Execution Cycle: Execution of a fetched instruction is called "execution cycle". Processor-memory data transfer between CPU and main memory Processor I/O Data transfer between CPU and I/O module Data processing Some arithmetic or logical operation on data Control Alteration of sequence of operations. e.g. jump Combination of above

Instruction Cycle: The processing time required for the execution of a single instruction is called an "instruction cycle". That is Instruction cycle = Fetch cycle + Execution cycle.

4|Page

Assignment #01

The following figure is showing the typical instruction format of 16 bits long, four bits are meant for representing 16 different operation codes (OP codes) (24 = 16) and 12 bits are meant for representing Address (i.e., 212 = 4096 (4k) words).

Figure - typical instruction format of 16 bits long

e.)
(i) A trap is a software-invoked interrupt. In computer programming, an attempt to divide by zero may, depending on the programming language and the type of number being divided by zero, generate an exception, generate an error message, crash the program being executed, generate either positive or negative infinity, or could result in a special not-a-number value. In software development, a breakpoint is an intentional stopping or pausing place in a program, put in place for debugging purposes. It is also sometimes simply referred to as a pause. More generally, a breakpoint is a means of acquiring knowledge about a program during its execution. During the interruption, the programmer inspects the test environment (general purpose registers, memory, logs, files, etc.) to find out whether the program is functioning as expected. In practice, a breakpoint consists of one or more conditions that determine when a program's execution should be interrupted. If the trap happens in user mode (in other words, if the trap is caused by a user process), the kernel usually sends a signal to the process. For example, if a process executes an instruction that causes a divide-by-zero error, the CPU raises a divide-by-zero exception, and the trap handler ultimately sends a SIGFPE (floating point error) signal to the process. Some user exceptions are legal and do not cause a signal. For example, a process may de-reference a valid pointer that identifies a piece of data in the process's data segment that is currently paged out of main memory. The CPU raises a page fault, and the trap handler then loads the page of data from the swap area into memory and restarts the instruction that caused the fault. In this case, the trap handler does not send a signal to the process. (ii) Interrupts An interrupt is a signal that stops the current program forcing it to execute another program immediately. The interrupt does this without waiting for the current program to finish. It is unconditional and immediate which is why it is called an interrupt. The whole point of an interrupt is that the main program can perform a task without worrying about an external event.

5|Page

Assignment #01

For example, if the processor is transferring data to a printer by using the instruction cycle scheme. After each WRITE operation, the processor is to pause and remain idle until the printer catches up. Here the processor time is wasting. This is depicted in the figure below:

Interrupt Processing

The occurrence of an interrupt triggers a number of events, both in the processor hardware and in software. Two approaches for dealing with multiple interrupts are: Disabled interrupts while an interrupt is being processed. This is shown in the figure below:

1. CPU initiates IO operation to a device and goes about its normal processing. 2. Device completes IO and sends interrupts signal to the processor. 3. Processor completes current instruction before responding to the interrupt. 4. Processor determines the source interrupt and sends acknowledgment. 5. Processor them saves its current state and transfer control to interrupt handler. 6. Interrupt handler (or Interrupt Service Routine-ISR) completes execution and returns control to the main routine by restoring the saved context from step 5. 7. Processor resumes its normal processing. (iii) Characteristics Despite the different causes of Traps, interrupts, supervisor calls, and subroutine calls, they share a common format for their handling routines

6|Page

Assignment #01

[Q03.]
1. Processor Management A program does nothing unless its instructions are executed by a CPU. A process is defined as a program in execution. A process needs certain resources, including CPU time, memory, files and I/O devices to accomplish its task. Program by itself is not a process. A program is a passive entity, such as the contents of a file stored on disk. Process is an active entity, with a program counter specifying the next instruction to execute. The execution of a process progress in a sequential fashion. A process is the unit of work in a system. Some of which are operating system processes and remaining are user processes. Operating system activities in connection with Process Management Creation and deletion of both user and system processes.

Suspension and resumption of processes. Provision of mechanisms for process synchronization. Provision of mechanisms for process communication. Provision of mechanisms for deadlock handling.

2. Memory Management Main-memory is a large array of words or bytes, ranging in size from hundreds of thousands to hundreds of millions. The central processor reads instructions from main-memory during the instruction-fetch cycle, and both reads and writes data from main memory during the data-fetch cycle. The I/O operations implemented via DMA also read and write data through main memory. To process data from disk, first transferred to main memory. To improve both the utilization of CPU and the speed of the computer's response, keep several programs in memory. Selection of a memory-management scheme depends on many factors. Operating system activities in memory-management Keep track of which parts of memory are using by whom.

Which processes are loaded into memory and when memory space becomes available? Allocate and deallocate memory space as needed

3. File Management Computers can store information on several different types of physical media, such as magnetic tape, magnetic disk, optical disk, etc. These media properties include speed, capacity, and data transfer rate and access method (sequential or random). A file is a collection of related information defined by its creator. Commonly files represent programs (source and object) and data. Data files may be numeric, alphabetic or alphanumeric. Files are organized into directories to ease their use.

7|Page

Assignment #01

Operating System activities in File Management Creation and deletion of files.


Creation and deletion of directories. Manipulating files and directories. Mapping of files onto secondary storage. Backup of files on stable (non-volatile) storage media.

4. Device Management Input / Output System Management Operating system is to hide the peculiarities of specific hardware devices from the user, only the device driver knows the peculiarities of the specific device to which it is assigned. Operating system activities with respect to I/O sub-system

Memory management component including buffering, caching and spooling. A general device-driver interface. Drivers for specific hardware devices.

Secondary-Storage Management The main purpose of a computer system is to execute programs. These programs, with the data they access must be in main memory during execution. Most programs including compilers, assemblers, sort routines, editors and formatters are stored on a disk until loaded into main memory. Operating System activities in disk management Free-space management.

Storage allocation. Disk scheduling.

5. System Security If a computer system has multiple users and allows the concurrent execution of multiple processes, then the various processes must be protected from one another's activities. Operating system activities in protecting systems Device control registers are not accessible to users.

Controlling the access of programs, processes or users. To distinguish between authorized and unauthorized usage.

REFERENCES
[Q01.] http://www.linfo.org/kernel.html [Q02.] William Stallings Computer Organization and Architecture 6th Edition [Q03.] http://en.wikipedia.org/wiki/Operating_system

8|Page

You might also like