Tuesday, July 6, 2021

CST 334 Operating Systems Module 2 : Systems

1.0 Topics Covered: After completing this module, you should be able to:

1.0.1 Define ‘process’, and describe the difference between a program and a process.

  • A process is essentially running a program (book).
  • A process is a program that provides a set of services such as file management to ensure that program has a framework and an environment to run in. 
  • A process is a sequence of computer instructions executing within a restricted environment which includes: 
    • An address space (memory, memory map)
    • A set of CPU registers 
    • The ability to invoke system calls   

 1.0.2 Name process states 

  • Polling - Either the operating system or process itself is repetitively querying a device to see if the I/O has completed (very wasteful in using CPU resource). 
  • Running - ONLY ONE PROGRAM CAN BE RUNNING PER CPU
  • Blocking - run to block instead of waiting for I/O. puts process to sleep and selects another ready-to-run process to run.
  • Ready - ready to run
1.0.2 Describe transitions between process states
  • A process is running if the process is assigned to a CPU. A process is removed from the running state by the scheduler if a process with a higher priority becomes runnable. A process is also pre-empted if a process of equal priority is runnable when the original process consumes its entire time slice.

  • A process is runnable in memory if the process is in primary memory and ready to run, but is not assigned to a CPU.

  • A process is sleeping in memory if the process is in primary memory but is waiting for a specific event before continuing execution. For example, a process sleeps while waiting for an I/O operation to complete, for a locked resource to be unlocked, or for a timer to expire. When the event occurs, a wakeup call is sent to the process. If the reason for its sleep is gone, the process becomes runnable.

  • When a process' address space has been written to secondary memory, and that process is not waiting for a specific event, the process is runnable and swapped.

  • If a process is waiting for a specific event and has had its whole address space written to secondary memory, the process is sleeping and swapped.

    If a machine does not have enough primary memory to hold all its active processes, that machine must page or swap some address space to secondary memory.

  • When the system is short of primary memory, the system writes individual pages of some processes to secondary memory but leaves those processes runnable. When a running process, accesses those pages, the process sleeps while the pages are read back into primary memory.

  • When the system encounters a more serious shortage of primary memory, the system writes all the pages of some processes to secondary memory. The system marks the pages that have been written to secondary memory as swapped. Such processes can only be scheduled when the system scheduler daemon selects these processes to be read back into memory.

1.0.3 Explain, at a high level, how the OS manages processes
  • Process managements involve the execution of various tasks such as creation of processes, scheduling of processes, management of deadlock, and termination of processes. It is responsibility of operating system to manage all the running processes of the system. Operating system manages processes by performing tasks such as resource allocation and process scheduling. When a process runs on computer device memory and CPU of computer are utilized. The operating system also has to synchronize the different processes of computer system.
  • A process consists of set of instruction to be executed. A process is also associated with some data that is to be processed. There is also a state that is associated with a process at a particular instant of time called process state. Similar to these concepts, there are number of concepts associated with the process management function of an operating system.

1.0.4 Be able to write code using the C API (fork(), exec(), wait() )

  • exec() - The exec() family of functions replaces the current process image with a new process image. It loads the program into the current process space and runs it from the entry point.
  • wait() - A call to wait() blocks the calling process until one of its child processes exits or a signal is received. After child process terminates, parent continues its execution after wait system call instruction. 
    Child process may terminate due to any of these: 
    • It calls exit();
    • It returns (an int) from main
    • It receives a signal (from the OS or another process) whose default action is to terminate.
  • fork() - Fork system call is used for creating a new process, which is called child process, which runs concurrently with the process that makes the fork() call (parent process). After a new child process is created, both processes will execute the next instruction following the fork() system call. A child process uses the same pc(program counter), same CPU registers, same open files which use in the parent process.It takes no parameters and returns an integer value. Below are different values returned by fork().

    Negative Value: creation of a child process was unsuccessful.
    Zero: Returned to the newly created child process.
    Positive value: Returned to parent or caller. The value contains process ID of newly created child process.

1.0.5 Describe how Linux supports multi-programming

  • Because there are typically many processes running on a computer - all requiring CPU resources - the computer must schedule how the competing tasks are processed. On a single-processor (single core) machine, scheduling is performed by allocating small time slices to each process. The performance of the machine and the short span of time (milli-seconds) that each process is running makes it appear to the user that processes run concurrently.
     

No comments:

Post a Comment

CST 499 Capstone - Week 8 Learning Journal Final Entry

This is the very last entry of the journal of your CS Online learning!  Keeping regular journals is a great way for us to grow, both profe...