The Great Symbian

Anything under the sun goes here!

An operating system executes a variety of programs:

  • Batch System – jobs
  • Time-Shared Systems – user programs or tasks
  • Textbook uses the terms job and process almost interchangeably.

    PROCESS – a program in execution; process execution must progress in sequential fashion.
A process includes:
  • Program Counter

  • Stack

  • Data Section

A. PROCESS STATE



A process can be in one of many possible states:

  • New: The process is being created.

  • Running: Instructions are being executed.

  • Waiting: The process is waiting for some event to occur.

  • Ready: The process is waiting to be assigned to a process.

  • Terminated: The process has finished execution.


PROCESS TRANSITIONS

As a process executes, it changes its state


Fig. Process State Transition Diagram

B. PROCESS CONTROL BLOCK

  • Each process in the operating system is represented by a process control block (PCB) – also called a task control block.

  • Information associated with each process includes:
    - Process state – new, ready, running, waiting...
    - Process identification information
    ° Unique process identifier (PID) - indexes (directly or indirectly) into the process table.
    ° User identifier (UID) - the user who is responsible for the job.
    ° Identifier of the process that created this process (PPID).
    - Program counter – To indicate the next instruction to be executed for this process.
    - CPU registers – include index registers, general purpose registers etc. so that the process can be restarted correctly after an interrupt occurs.
    - CPU scheduling information – Such as process priority, pointers to scheduling queues etc.
    - Memory-management information – Include base and limit register, page tables etc.
    - Accounting information – Amount of CPU and real time used, time limits, account number, job or process numbers and so on.
    - I/O status information – List of I/O devices allocated to this process, a list of open files etc.





C. THREADS


  • A thread, also called a lightweight process (LWP), is the basic unit of CPU utilization.

  • It has its own program counter, a register set, and stack space.

  • It shares with the pear threads its code section, data section, and OS resources such as open files and signals, collectively called a task.

  • The idea of a thread is that a process has five fundamental parts: code ("text"), data, stack, file I/O, and signal tables. "Heavy-weight processes" (HWPs) have a significant amount of overhead when switching: all the tables have to be flushed from the processor for each task switch. Also, the only way to achieve shared information between HWPs is through pipes and "shared memory". If a HWP spawns a child HWP using fork(), the only part that is shared is the text.
  • Threads reduce overhead by sharing fundamental parts. By sharing these parts, switching happens much more frequently and efficiently. Also, sharing information is not so "difficult" anymore: everything can be shared.

User-Level and Kernel-Level Threads

  • There are tow types of thread: user-level and kernel-level.
  • User-level avoids the kernel and manages the tables itself.
  • These threads are implemented in user-level libraries rather than via system calls.
  • Often this is called "cooperative multitasking" where the task defines a set of routines that get "switched to" by manipulating the stack pointer.
  • Typically each thread "gives-up" the CPU by calling an explicit switch, sending a signal or doing an operation that involves the switcher. Also, a timer signal can force switches.
  • User threads typically can switch faster than kernel threads.

Thread States

  • Threads can be in one of the several states: ready, blocked, running, or terminated.
  • Like process, threads share the CPU and only one thread at a time is in running state.




























0 comments:

FEEDS

Add to Google Reader or Homepage