TimeLinux1

Sunday, May 15, 2011

OS Concepts - 1

OS Concepts:

-A very general definition of OS will be that it is:
    . a big program
    . that manages the hardware of a computer
    . on behalf of its users and other programs.
-the definition of an OS varies from the viewpoint it is looked at.
-a users definition of OS will differ from that of a program or that of the system itself.

-kernel - is that part of the OS that is intimately associated with hardware control and operation.
-kernel always runs on a computer.
-system programs are programs that are part of the OS but not part of the kernel.
-application programs are programs that are not part of the OS and are initiated by the user.

-a general purpose computer consists of cpus and device controllers connected via a system-bus.
-the device controllers control devices like memory, disk drives, video, keyboard etc.
-the cpu and device controllers can execute concurrently, competing for memory cycles.
-the memory cycles are in turn dependant on cycles of signals on the system-bus.
-typically the os has a device driver for each device controller.

-the bootstrap program that resides in the firmware, reads and loads the OS from disk to memory.
-once booted the os waits for some event to happen from either the s/w or h/w.
-events generated by h/w are called interrupts.
-events generated by s/w are called traps. traps are signalled by something called 'system calls'.
-the interrupts or traps are basically requests for cpu attention.
-during the event, the cpu stops what it is doing, stores the info in a fixed address in memory and attends to the event.
-once done with the event, it returs to the fixed address to resume its work.

-multiprogramming    - running multiple programs from one or more users simultaneously
-multitasking        - like multiprogramming but the tasks are from a single user.
-the above two ideas follow from that the system keeps many jobs in main memory simultaneously in a job pool.
-then it picks up jobs from the job pool to execute on the cpu. This is done by the scheduler.
-the switching between jobs is expected to be smooth so as to permit an effective end-user experience.

-to distinguish between user code and system code, two modes of os operation are defined:
    . user-mode and
    . kernel-mode
-they are set using a mode bit in the software.
-the mode bit allows the os to distinguish between a code from user or kernel.
-for user-mode,   mode bit is 1.
-for kernel-mode, mode bit is 0.
-eg: when a program run by a user requests a service from the os (via a system call), it changes the mode bit.
-at system boot, the h/w and os start in kernel mode.
-then the os starts user applications in user mode.
-when an event occurs (trap or interrupt), the h/w and os switch from user mode to kernel mode.
-this dual mode of operation protects the system from crashing due to runaway user programs.
-this is because the h/w allows privileged instructions to be run only in kernel mode.
-if an attempt is made by user program to run a privileged h/w instruction, then the h/w traps it to the os.
-the os shows an appropriate error message and the memory space for the user program may be dumped.
-the only way an user program can request h/w service is through a system call.
-note: intel 8088, on which dos ran, did not have the mode bit. so a runaway user program could crash the system.
-note: process failure causes memory to be dumped into a file called 'core dump'.
-note: kernel  failure causes kernel to create a file called 'crash dump'. kernel failure=crash.

-process is a program in execution.
-to become a program in execution, a process needs cpu time, memory, files and io devices.
-a process can have one or more threads in it.
-a thread is a sequence of instructions within a process.
-a single threaded process has one program counter.
-a multi  threaded process has one program counter for each thread.
-a program counter specifies the next instruction to be executed by the cpu.
-many processes can execute concurrently by multiplexing on a single cpu.

-cpu and memory are tighly integrated to work together.
-during process execution, cpu constantly reads and writes instructions from the memory.
-for a program to be executed as a process, it must be mapped and loaded to a fixed address in memory.
-this address in memory is called address space.
-in a multiprogramming system, the address space for each process needs to be isolated from others.
-yet at the same time, the processes must be able to share resources for efficiency.
-these present design and implementation challenges to the os.

... continued ...

No comments:

Post a Comment