Skip to document
This is a Premium Document. Some documents on Studocu are Premium. Upgrade to Premium to unlock it.

CSCI 340 Self taken Notes

Operating System Lecture Notes for Prof Simina Fluture. This is not a...
Course

Operating Systems Principles (CSCI 340)

16 Documents
Students shared 16 documents in this course
Academic year: 2021/2022
Uploaded by:
0followers
11Uploads
2upvotes

Comments

Please sign in or register to post comments.

Preview text

CSCI 340 Notes

Process Control Block (PCB) For each process, the operating system maintains the data structure which keeps track of complete information about that process. This data structure or record is called Process Control Block.

Following is the PCB structure Process ID Program Counter Process State Priority Registers Lists of Open files I/O devices Protection .........

Process ID: Unique Number is given to each process by the Operating System.

Program Counter:

Process State: State of the program whether they are being executed CPU or not. Ex: Executed, Terminated, Waiting, Ready to execute, Suspended, New program. If a program is being executed by CPU then its state is Executing, Process that’s completed execution is in the Terminated state. Process in RAM ready for execution is in Ready state.

Priority: Process of execution based on priority. Programs that have the highest priority will be executed first and the programs that have the lowest priority will be executed last. For example, the Operating System process has the highest priorities, and the user process has the lowest priority.

Registers: It is a small amount of fast memory that the CPU uses for storage during execution.

Lists of Open files: I/O devices Protection

Distributed Operating System: Operating system that has many computers to handle jobs

Clustered System: The system that is composed of two or more individual computer systems joined together. This system shares common storage and is closely linked through a

local area network. Each computer is called a node, and, in most cases, it shares the Hardware, and in some cases, it shares the Operating system.

Deadlock Operating System: A set of the process of processes is deadlocked when every process in the set is waiting for the resource that is allocated to another process in the set. We can say there is a deadlock if the following conditions are true. i- Mutual Exclusion: It will have two different types of resources that are shareable and unshareable. In shareable, multiple processes can access resources at the same time. On the other hand, in non-shareability, only one process can access resources at a time. The printer is a non-shareable resource. Resources for which processes are waiting must be mutual exclusive (i. Non-Shareable)

ii- No Preemption

iii- Hold and Wait

iv- Circular Wait

Simple Structure:

Process states: i- New: The process that has been created that hasn’t been executed yet. It is stored in secondary memory to ii- Ready: The process that is waiting to be executed after the termination of the process that’s executing. iii- Running iv- Wait/Block: This can happen when a process with high priority comes, it will stop the process being executed and execute the process with high priority. v- Termination vi- Suspended wait vii- Suspended block

Process Creation: A process may create several new processes, via a create-process system call, during the course of execution. - The process that creates another process is called a parent processor, and the new processes are called the children of that process. - Each of these processes may in turn create other processes, forming a tree of processes. - When a process creates a new process, two possibilities exist in terms of execution: i- The parent continues to execute concurrently with its children. ii- The parent waits until some or all of its children have terminated.

i- man top ii- Type q to stop running top

Starvation (Lived lock): Starvation in computer science is a problem encountered in concurrent computing where a process is perpetually denied necessary resources its process its work. Starvation may be caused by errors in a scheduling or mutual exclusion algorithm, but can also be caused by resources leaks, and can be intentionally caused via a denial-of-service attack such as a fork bomb.

Solution of starvation: aging

Deadlock (Circular waiting): Deadlock in concurrent programming is a situation in which two or more competing actions are each other to finish, and thus neither ever does.

Mutual Exclusion: In computer science, mutual exclusion is a property of concurrency control, which is instituted for the purpose of preventing race conditions; it is the requirement that one thread of execution never enter its critical section at the same time that another concurrent thread of execution enters its own critical section.

The requirement of mutual exclusion was first identified and solved by Edsger W. Dijkstra in his seminal 1965 paper titled Solution of a problem in concurrent programming control, which is credited as the first topic in the study of concurrent algorithms.

A simple example of why mutual exclusion is important in practice can be visualized using a singly linked list of four items, where the second and third are to be removed. The removal of a node that sits between 2 other nodes is performed by changing the next pointer of the previous node to point to the next node (in other words, if node i is being removed, then the next pointer of node i - 1 is changed to point to node i + 1, thereby removing from the linked list any reference to node i). When such a linked list is being shared between multiple threads of execution, two threads of execution may attempt to remove two different nodes simultaneously, one thread of execution changing the next pointer of node i - 1 to point to node i + 1, while another thread of execution changes the next pointer of node i to point to node i + 2. Although both removal operations complete successfully, the desired state of the linked list is not achieved: node i + 1 remains in the list, because the next pointer of node i - 1 point to node i + 1.

This problem (called a race condition) can be avoided by using the requirement of mutual exclusion to ensure that simultaneous updates to the same part of the list cannot occur.

Two process software solution:

Peterson’s Algorithm

  • Two process solution

  • Assume that LOAD and STORE instructions are atomic; that is, cannot be interrupted.

  • The two processes share two variables: i- Intturn; ii- Booleanflag[2]

  • The variableturnindicates whose turn it is to enter the critical section

  • Theflagarray is used to indicate if a process is ready to enter the critical section. Flag[i]= true implies that process piis ready.

int turn; Boolean flag [2];

do { flag[i] = TRUE; turn = j; while(flag[i] && turn == j) Critical Section Flag[i] = FALSE; Remainder Section } while(TRUE)

System Calls:

The interface between a process and an operating system is provided by system calls. In general, system calls are available as assembly language instructions. They are also included in the manuals used by the assembly-level programmers. System calls are usually made when a process in user mode requires access to a resource. Then it requests the kernel to provide the resource via a system call.

A figure representing the execution of the system call is given as follows −

Device Management

setConsoleMode() readConsole() writeConsole()

ioctl() read() write()

Information Maintenance

GetCurrentProcessID() SetTimer() Sleep()

getpid() alarm() sleep()

Communication

CreatePipe() CreateFileMapping() MapViewOfFile()

pipe() shmget() mmap()

Process Synchronization:

javatpoint/os-process-synchronization-introduction

The process enters its critical section once it starts the execution of the first command of its critical section. Once the process finishes the last command of its critical section, we say that the process exits its critical section. Threads can have critical sections in absolutely the same way that processes can.

Critical Section: The regions of a program that try to access shared resources and may cause race conditions are called the critical section. To avoid race conditions among the processes, we need to assure that only one process at a time can execute within the critical section.

Critical section problem:

1- Find a way to program different processes with critical sections so that: - Once one process enters its critical section, other processes cannot enter their actual critical sections until this process exits its critical section. This is called mutual exclusion. - When multiple processes want to enter their critical sections and no process is in its critical section, then one should enter it, and the choice of this process cannot be postponed indefinitely. This is called progress.

2- Consider a system consisting of n processes {P0, P1, ..., Pn}. Each process has a segment of code, called a Critical Section, in which the process may be changing common variables,

updating a table, writing a file, and so on. When one process is executing in its critical section, no other process is to be allowed to execute in its critical section. That is, no two processes are executing in their critical sections at the same time.

The Critical section problem is to design a protocol that the processes can use to cooperate.

Rules: - Each process must request permission to enter its critical section. - the section of code implementing this request is the entry section. - The critical section may be followed by an exit section. - The remaining code is the remainder section.

This is the general structure of a typical process:

do{ entry section

Critical Section

exit section

remainder section

}while(TRUE);

A solution to the critical section problem must satisfy the following three requirements:

1- Mutual Exclusion: If process Pi is executing in the critical section, then no other processes can be executing in their critical sections.

2- Progress: If no process is executing in its critical section and some processes wish to enter their critical sections, then only those processes that are not executing in their remainder sections can participate in the decision on which will enter its critical section next, and this selection cannot be postponed indefinitely.

3- Bounded waiting:

Was this document helpful?
This is a Premium Document. Some documents on Studocu are Premium. Upgrade to Premium to unlock it.

CSCI 340 Self taken Notes

Course: Operating Systems Principles (CSCI 340)

16 Documents
Students shared 16 documents in this course
Was this document helpful?

This is a preview

Do you want full access? Go Premium and unlock all 9 pages
  • Access to all documents

  • Get Unlimited Downloads

  • Improve your grades

Upload

Share your documents to unlock

Already Premium?
CSCI 340 Notes
Process Control Block (PCB)
For each process, the operating system maintains the data structure which keeps track
of complete information about that process. This data structure or record is called Process
Control Block.
Following is the PCB structure
Process ID
Program Counter
Process State
Priority
Registers
Lists of Open files
I/O devices
Protection
………
Process ID: Unique Number is given to each process by the Operating System.
Program Counter:
Process State: State of the program whether they are being executed CPU or not. Ex:
Executed, Terminated, Waiting, Ready to execute, Suspended, New program. If a program is
being executed by CPU then its state is Executing, Process that’s completed execution is in
the Terminated state. Process in RAM ready for execution is in Ready state.
Priority: Process of execution based on priority. Programs that have the highest priority will
be executed first and the programs that have the lowest priority will be executed last. For
example, the Operating System process has the highest priorities, and the user process has the
lowest priority.
Registers: It is a small amount of fast memory that the CPU uses for storage during
execution.
Lists of Open files:
I/O devices
Protection
Distributed Operating System: Operating system that has many computers to handle jobs
Clustered System: The system that is composed of two or more individual computer
systems joined together. This system shares common storage and is closely linked through a

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.

Why is this page out of focus?

This is a Premium document. Become Premium to read the whole document.