Friday 8 May 2020

Peterson Solution








Using Flag Variable for Critical Section Problem







Using Turn Variable for Critical Section Problem





PRODUCER CONSUMER PROBLEM




Critical Section








Process Synchronization






CPU Scheduling
















Introduction and Evolution of Operating Systems











Sunday 19 April 2020

Data Types in Python- Lecture 6- range




range Data Type:

range Data Type represents a sequence of numbers. 
The elements present in range Data type are not modifiable. i.e range Data type is immutable.

Form-1:

 range(10) generate numbers from 0 to 9



Form-2: range(10,20)

generate numbers from 10 to 19

 

Form-3: range(10,20,2)

2 means increment value by 2




 

We can access elements present in the range Data Type by using 
  • loops
  • index.
Using loops:



Using Index:



We cannot modify the values of range data type
Example:  
r[0]=100 
TypeError: 'range' object does not support item assignment


We can create a list of values with range data type
Example:
1) >>> l = list(range(10))
2) >>> l 
3) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

Friday 17 April 2020

Data types in Python - Lecture 5- bytes and bytearray




bytes Data Type:

bytes data type represents a group of byte numbers just like an array.
The only allowed values in bytes data type are in range of 0- 256

example:
x=[10,20,30,40,50]
b=bytes(x)
type(b)----> bytes


 
You can save numbers in bytes datatype object but only in a particular range(0,256)
If you try to save a number out of this range you will get ValueError:
 


In Python if you talk about range(0,256) you mean the allowed numbers are 0 to 255 , Therefore even 256 is not allowed in bytes


bytes is IMMUTABLE
therefore item assignment is not allowed
If you try so, you will get TypeError




bytearray Data type:

bytearray is exactly same as bytes data type except that its elements can be modified.