0%

CS302 Operating System Week2 Note

Process

  • A Process is an execution instance of a program
    • More than one process can execute the same program code

Process vs. program

  • A process has states concerning the execution.
    • Which line of codes it is running
    • How much time left before returning the CPU to others
  • Linux commands about processes
    • ps: "process status", it can report a vast amount of information about every process in the system.
    • top: allows users to monitor processes and system resource usage on Linux

What is a Shell?

  • A shell is a program, open a "terminal", actually launches a "shell" process
    • Bash in linux
  • Written in C
    • use getchar() to get your command "ps"
    • syntax checking
    • invoke a function fork() (a system call) to create a new process
      • i.e., becoming a child process of the shell
    • Ask the child process to exec() the program "ps"

Process hierarchy

  • Process relationship
    • A parent process will have its child processes
    • Also, a child process will have its child processes
    • This forms a tree hierarchy

System call

  • a function call
  • exposed by the kernel
  • abstract away most low-level details
  • Categorizing system calls
    • Process, File system, Memory, Security, Device
  • How can we know if a "function' is a system under linux
    • Read the man page "syscalls" under linux

System calls VS Library function call

  • Library functions are usually compiled and packed inside an object called the library file
    • In Windows: .DLL - dynamically linked library
    • In Linux: .So - shared objects

What will we learn about Process

  • System calls
    • Hoa to program a simple, bare-bone shell?
  • Lifecycle and Scheduling
    • How to create processes?
    • How to handle the death of the processes
    • Which process shall get the core next?
  • Signals
    • How to suspend a process
  • Synchronization

The Memory of a Process

Memory

  • Virtual memory
    • Your process virtually owns all your machine's RAM
  • Memory-related functions
    • E.g., how to write "malloc()"

File System

  • Each disk can have multiple FSs
  • An OS may understand different FSs

OS_L02_fundamental

Four Components of a Computer System

  • computer hardware
  • operating system
  • system and application programs
  • user(human being or program)