Week 2 - Threads and process synchronization

Describe process, process state, and process control block.

Process – A process is essentially a program that is currently running. Normally a program will become a process when an executable or a desktop shortcut is run which then loads into memory. A process will usually take on many other entities as it executes which include items such as the process stack which is temporary data, a data section which is global variables, and heap which is dynamically allocated memory.

Process state – A process state is typically what is happening while a process is executing. While a process is running, it is changing state which are as follows:

  • New − The process created.
  • Running − Instructions are being executed.
  • Waiting − Waiting for an event to occur (I/O operation or receiving a signal).
  • Ready − Waiting to be assigned to a processor.
  • Terminated − The process has completed execution.

While many programs can be running at once, the process states can only be run once at a time and cannot start until the previous process state has been completed.

Process control block – A processing control block (PCB) is a representation of the process within the operating system. It is also referred to as a task control block. The PCB contains many data items which are as follows:

Process State: The process state (new, ready, running, waiting or terminated)

Process Number: The number of the processes.

Program Counter: The address of the next instruction to be executed.

Registers: The registers that are used by the process may include accumulators, index registers, stack pointers, general purpose registers etc.

List of Open Files: The different files associated with the process

CPU Scheduling Information: The priority list of process via the CPU scheduling that is contained in the PCB.

Memory Management Information: This includes the page or segment tables depending on the memory system used. It also contains the value of the base registers, limit registers etc.

I/O Status Information: This includes the list of I/O devices used by the process, the list of files etc.

Accounting information: This part of the PCB which includes time limits, account numbers, amount of CPU used, process numbers etc.

 

Compare single- and multi-threaded motivations and models.

A single-threaded process is just as the name states and can only run one single process at a time. While a process can run via single-threaded with no true issues, it will take much more time for the process to complete. In today’s tech world, single-threading isn’t used as often.

A multithreaded process is the opposite of a single thread and can run multiple parts of a program at once. This allows for faster performance and the ability to complete a process in a shorter amount of time. Many of the benefits of multi-threading come in four categories: responsiveness, resource sharing, economy, and scalability. Multi-threading is a more common model these days.


Describe the critical-section problem and explain a software solution that resolves this problem.

 With the critical-section, there are multiple segments of code running different items at once, such as writing a file, or updating a table, but can only execute in the critical-section one at a time. The critical-section problem is what allows processes to cooperate and request permission to enter its critical-section. This is also known as the entry section and followed by an exit section. If there is any remaining code, it is typically within what is considered the remainder section. There is a solution, but it must complete the following requirements of mutual exclusion, progress, and bounded waiting.

A software-based solution that resolves the problem is also known as Peterson’s solution. This concept only allows for two processes that alternate their executions between the critical and remainder sections. It also requires for the two processes to share data items and ensures mutual exclusion. Peterson’s solution can be implemented on any platform due to no hardware support is required since it runs in user mode.





- Click the link below to view the concept map for week 2 - 


Comments

Popular posts from this blog

Final Project Summary

Week 1 - Major functions of an Operating System

Week 4 - Files, mass storage, and I/O