OS proess and threads
Printed From: One Stop GATE
Category: GATE Technical Discussions
Forum Name: GATE CS
Forum Discription: General Technical Discussions, Queries, doubts etc. for GATE in CS.
URL: http://forum.onestopgate.com/forum_posts.asp?TID=1104
Printed Date: 04Jul2025 at 10:14pm
Topic: OS proess and threads
Posted By: gita
Subject: OS proess and threads
Date Posted: 08Apr2007 at 11:32pm
- A process is an execution stream in the context of a particular
process state.
- An execution stream is a sequence of instructions.
- Process state determines the effect of the instructions. It
usually includes (but is not restricted to):
- Registers
- Stack
- Memory (global variables and dynamically allocated memory)
- Open file tables
- Signal management information
Key concept: processes are separated: no process can directly affect the state
of another process.
- Process is a key OS abstraction that users see - the environment
you interact with when you use a computer is built up out of processes.
- The shell you type stuff into is a process.
- When you execute a program you have just compiled, the OS
generates a process to run the program.
- Your WWW browser is a process.
- Organizing system activities around processes has proved to be
a useful way of separating out different activities into coherent
units.
- Two concepts: uniprogramming and multiprogramming.
- Uniprogramming: only one process at a time. Typical example:
DOS. Problem: users often wish to perform more than one activity
at a time (load a remote file while editing a program, for example),
and uniprogramming does not allow this. So DOS and other uniprogrammed
systems put in things like memory-resident programs that invoked
asynchronously, but still have separation problems. One key problem with
DOS is that there is no memory protection - one program may write
the memory of another program, causing weird bugs.
- Multiprogramming: multiple processes at a time. Typical of Unix
plus all currently envisioned new operating systems. Allows system
to separate out activities cleanly.
- Multiprogramming introduces the
resource sharing problem - which processes get to use the physical
resources of the machine when? One crucial resource: CPU. Standard
solution is to use preemptive multitasking - OS runs one process
for a while, then takes the CPU away from that process and lets
another process run. Must save and restore process state. Key issue:
fairness. Must ensure that all processes get their fair share of the
CPU.
- How does the OS implement the process abstraction? Uses a
context switch to switch from running one process to running
another process.
- How does machine implement context switch? A processor has a
limited amount of physical resources. For example, it has only
one register set. But every process on the machine has its own
set of registers. Solution: save and restore hardware state on
a context switch. Save the state in Process Control Block (PCB).
What is in PCB? Depends on the hardware.
|
|