07 CSC520 03 Bahan Pengajaran Chapter 03 Process

Chapter 3: Processes

3.1 Overview

  • Introduces key concepts about operating system processes.

  • Discusses topics such as process scheduling, operations on processes, interprocess communication (IPC), and client-server communication.

3.2 Process Concept

  • Definition: A process is a program in execution, which includes:

    • Program code (text section)

    • Current activity (program counter, registers)

    • Stack (temporary data)

    • Data section (global variables)

    • Heap (dynamic memory)

  • Programs are passive entities stored on disk; processes are active when loaded into memory.

3.3 Process States

  • States of Process:

    • New: Being created

    • Running: Currently executing

    • Waiting: Awaiting an event

    • Ready: Ready to run but not currently executing

    • Terminated: Finished execution

3.4 Process Control Block (PCB)

  • Contains information about each process:

    • Process state

    • Program counter

    • CPU registers

    • CPU scheduling information

    • Memory management information

    • Accounting information

    • I/O status information

3.5 Process Scheduling

  • Scheduler Types:

    • Short-term scheduler (CPU scheduler): Allocates CPU to processes quickly (invoked frequently).

    • Long-term scheduler: Selects processes for the ready queue (invoked infrequently).

    • Medium-term scheduler: Manages swapping processes in and out of memory.

  • Process migration: Processes move through job queue, ready queue, and device queues.

3.6 Interprocess Communication (IPC)

  • Types of IPC:

    • Shared Memory: Processes access common memory region. Synchronization is crucial.

    • Message Passing: Processes communicate with messages through send/receive operations.

  • Process cooperation: Benefits include speedup, modularity, and information sharing.

3.7 Synchronization Models

  • Blocking vs. Non-blocking:

    • Blocking (synchronous): The sender or receiver is blocked until the operation completes.

    • Non-blocking (asynchronous): The sender/receiver may proceed without waiting.

3.8 Examples of IPC Systems

  • POSIX: Allows shared memory through shm_open() and mmap().

  • Mach: Utilizes message-based communication.

  • Windows: Advanced local procedure call (LPC) for message-passing.

  • Client-Server Communication: Sockets, remote procedure calls (RPC), pipes.

3.9 Sockets

  • Defined as endpoints for communication between two programs.

  • Combination of IP address and port number.

3.10 Conclusion

  • Understanding processes and their management is essential for effective OS design.