Saturday, July 6, 2024

Week 2:

 

Week 2: Process Management and Shell Scripting

  • Topics:
    • Processes and process states
    • Process control block (PCB)
    • Context switching
    • Basic shell scripting
  • Activities:
    • Lab: Writing simple shell scripts
    • Discussion forum: The role of processes in an OS
    • Quiz: Process Managemen-------
    • outline focusing on Processes and Process States, Process Control Block (PCB), Context Switching, and Basic Shell Scripting:

      Topics:

      1. Processes and Process States:

        • Definition and Characteristics of a Process:

          • A process is an instance of a program that is being executed. It consists of program code, data, and resources (CPU time, memory, I/O devices).
          • Characteristics include process ID (PID), state, priority, CPU registers, and memory space.
        • States of a Process:

          • New: The process is being initialized.
          • Ready: The process is ready to execute and waiting for CPU time.
          • Running: The process is currently being executed.
          • Waiting: The process is waiting for some event (e.g., I/O completion).
          • Terminated: The process has finished execution.
        • Process Control Block (PCB):

          • PCB is a data structure maintained by the operating system for each process.
          • It includes process state, program counter (PC), CPU registers, CPU scheduling information, and memory management information.
          • PCB allows the OS to manage and track processes effectively.
      2. Context Switching:

        • Definition and Purpose of Context Switching:

          • Context switching is the process of saving the state of a process (PCB) so that it can be resumed later and loading the state of another process to run.
          • Purpose: Allows multitasking and efficient sharing of CPU resources among multiple processes.
        • Mechanisms Involved in Context Switching:

          • Involves saving the current state of the running process (registers, PC, etc.) into its PCB.
          • Loading the saved state of the next process from its PCB into the CPU registers.
          • Switching memory address spaces if processes belong to different address spaces (e.g., virtual memory).
        • Context Switch Overhead and Optimization:

          • Overhead: Context switching consumes CPU cycles and introduces latency due to saving and restoring process states.
          • Optimization strategies include using efficient scheduling algorithms (e.g., preemptive scheduling) to minimize context switches and optimizing the context switch routines.
      3. Basic Shell Scripting:

        • Introduction to Shell Scripting:

          • Shell scripting involves writing scripts (sequences of commands) in a shell (command-line interpreter) language.
          • Common shells include Bash (Bourne Again SHell) on Unix/Linux and Command Prompt on Windows.
        • Writing Simple Scripts:

          • Tasks include automating file operations (copying, moving, deleting), text processing (searching, parsing), and system administration tasks (monitoring system resources, setting up environments).
        • Use Cases and Advantages:

          • Automating repetitive tasks to save time and reduce errors.
          • Facilitating batch processing and system administration tasks.
          • Integrating with system utilities and commands to perform complex operations efficiently.

      Activities:

      • Lab: Writing Simple Shell Scripts

        • Task: Write shell scripts to automate common tasks such as file management, text processing, or system monitoring.
        • Objective: Gain hands-on experience with basic shell commands, scripting syntax, and understanding of process interaction in scripts.
      • Discussion Forum: Process States and Context Switching

        • Topic: Discuss the lifecycle of processes and the impact of context switching on system performance.
        • Points to Consider: How do different process states affect system resources? What are the challenges in managing context switches effectively?
      • Quiz: Understanding Processes and Shell Scripting

        • Format: Multiple-choice and short-answer questions.
        • Scope: Covers topics such as process states, PCB structure, context switching mechanisms, and basic shell scripting concepts.

      Recommended Resources:

      • Textbook: "Operating System Concepts" by Abraham Silberschatz, Peter B. Galvin, and Greg Gagne.
      • Additional Reading: "The Linux Command Line" by William Shotts, for practical guidance on shell scripting and command-line utilities.

Pages