Software Engineer, Your next Programming Instructor.

"Here I share myself."
Showing posts with label operating system. Show all posts
Showing posts with label operating system. Show all posts

Saturday, 18 July 2020

Thread in Operating System | Thread VS Process

What is Thread in Operating System?


First of all you should know that a thread is also known as lightweight process.

It is a sequence of instruction within a process. A thread itself behave like a processes in a process.

It behave like a process within the process, but it don’t have a complete PCB it relays on the PCB of the process under which it is behaving like a process.

A process can have multiple threads, all those multiple threads in the process help the process to perform multiple executions which improves the working.

There must be at least one thread in a process.

A thread pass through three states:
  1. Running
  2. Ready
  3. Blocked 

Benefits of Threads:

It share common data and do not use the Inter process communication.

Speed improvement when multiple threads cooperate to complete a single job.

Context switching becomes fast when working with threads.

Threads use very little recourses of OS as they don’t demand complete separate PCB.

It share common data and do not use the Inter process communication.

Speed improvement when multiple threads cooperate to complete a single job.

Context switching becomes fast when working with threads.

Threads use very little recourses of OS as they don’t demand complete separate PCB.





Sunday, 5 July 2020

IPC model | Shared memory model | Message passing model in OS

Inter-Process Communication | Shared Memory Model | Message Passing Model in Operating System

Software Engineering,mysoftwarenotes.com,mysoftwarenotes,software developer,software,operating system tutorial,operating system course,ipc in operating system,ipc in operating system in hindi,shared memory model in os,message passing model in,message passing model in os,message passing model in operating system,message passing model in distributed system,symmetric communication in os,asymmetric communication is os,os in hindi easy engineering classes


•IPC – (Inter-Process Communication) is the capability which allow two process of the computer to communicate with each other.

•Where will be those process?
•Its not important for process to be in the same computer they can be in same computer or in different computer which are connected over the network.

•There are two fundamental model of Inter Process Communication.
•1) Shared Memory Model
•2) Message Passing Model

Shared Memory Model
•This model made a region of memory which get shared between the cooperating processes.

•The process who want to share information read and write the data from this location.

•This is the fast model as compare to the Message passing model.

Where this shared memory is located?

You may find this shared memory under the address space of the process which want to share data with other processes.

•Yup, That’s true that OS usually prevent the process to inter in the memory of other process but in this scenario, we bypass this prevention.
•OR the process itself allow the OS to remove this protection from its memory for the cooperating processes.

Message Passing Model
In this model two process communicate with each other by passing messages.

•It is easy to implement as compare to shared memory model.

•It is useful to exchange small amount of data.

•This system is much more useful in the distributed environment when the two computers are on the same network and their processes want to share the data.

Message Passing Model Operations:

Message passing model provide two operations
1.Send(Message)
2.Receive(Message)

In sending message and receiving message, there are two more concepts.
1.Direct Communication
    1.1.Symmetric Communication
    1.2.Asymmetric Communication
2.Indirect Communication

Direct Communication:
In direct communication sender and receiver mention the name of the process from which they want to receive messages or to whom they want to send messages.

In Symmetric communication both sender and receiver mention the name of each other.

in Asymmetric Communication Only sender mention the name of the receiver, receive the message from the ID.

Indirect Communication:
•In this system messages are sent and receive from the mailbox.

•Mailbox is a place where two or more process store and remove messages.

•Processes communicate sharing one mailbox.

Video Lecture on the Topic

Tuesday, 30 June 2020

IPC- Inter Process Communication



Inter Process Communication - IPC in Operating System
•IPC – (Inter-Process Communication) is the capability which allow two process of the computer to communicate with each other.

•Where will be those process?
•Its not important for process to be in the same computer they can be in same computer or in different computer which are connected over the network.

•IPC allow one application to control other application, It also allow two applications to share data with each other.

•IPC is an important thing in the multiprogramming system, or we can say multiprogramming system depends on this system,

•Single process Operating system do not use IPC.

•Microsoft windows is a Multiprogramming operating system and it use the IPC. In windows IPC is known as Dynamic Data Exchange System.

•In an OS (Multiprogramming OS) many process may be running at the same time. In the context of IPC we can divide those processes into two main categories.

1.Independent Process
2.Cooperating Process

Independent Process 
•As name shows in the Multiprogramming OS environment these processes are work independently.
•They never ask any other process to share data and never share their own data to some other process.
•Although they are in the Multiprogramming OS but they never share data.

Cooperating Process
•Name is telling the whole store these are just opposite to the independent process and share the data with other cooperating process into the system.

•Different advantages of process cooperation:
1.Information Sharing
2.Computation Speed up
3.Modularity
4.Convenience

Computation Speed up
•Task get divided into multiple tasks, all task run parallel and achieve the required results.

Modularity
•Divide a function into separate process and threads.

Convenience
•If user is using the same data in different tasks conflict can be arise so this system try to avoid conflicts.

•There are further two memory models in this system.
•Shared Memory Model
•Message Passing System


Sunday, 5 April 2020

Operating System Process Termination Exit(), Abort() | Zombie and Orphan process in Operating System

Zombie and Orphan Process,Operating System,Software Engineering,mysoftwarenotes.com,mysoftwarenotes,difference between zombie and orphan process,difference between zombie and orphan process in linux,zombie and orphan process difference,explain zombie and orphan processes,process termination in operating system,process creation and termination in operating system,process termination in os,what is process termination in os,types of process termination in os,OS
Operating System Process Termination

Operating System Process Termination Exit(), Abort() | Zombie and Orphan process in Operating System

In the last lecture we discussed about the process creation and Child process in details.

In this lecture we gona cover the following topics.
1. What is process termination?
2. How a child process terminates
3. What is the Orphan Process
4. What is the concept of Zombie process.

1. Process Termination:When a process startes working it have to get terminated after finishing its task this is the normal way of termination but sometime a process get hangs or a process start troubling you so you also kill the process to keep your experience smoth this is also process termination.On the termination a process gives the Exit() call to the OS so the operating system can know the process has been terminated.

2.Child process termination:
Child terminates by finishing its task and it also return the data or say results of the task to the parent process.
Parent process can also send the Abort() call to child to terminate its processing and return the data to parent.
Some time we explaing this parent child behavior with the sentence "Parent reap the child process".
The word reap means getting/Obtaining something good in the result of something you did.
I hope now you can understand what does parent reap the child means.

3. Orphan process & its types:
So child has a parent but sometime the parent get terminated so the child becomes the orphan thats is what the orphan means.A child without his parent is known as the orphan.
Now there are two different situations or say diferent types of Orphans.
Some child becomes the orphan intentionally others becomes unintentionally what does that mean?

3.1:Intentionally Orphan: Parent is busy in doing his task and child as well but the parent manages to complete his task early and want to terminates.
Normally when a parent terminates its child also terminates as well.
Here the parent has completed its task and want to terminate but the child still have a lot of work to do so the child will ask the parent dad you can get terminated I have a alot of work to do it may take some time I will terminate latter. The parent will get terminated and the child will become orphan intentionally.

3.2: Unintentionally Orphan: this is simple a child may not want his parents to get terminated like in above case but someone kills the parent.
Who and why someone kills the parent?
If a parent get hangs or create some other problems and distrub the computer user may be the end user will kill the parent to avoid the troubles in usage and there can be many more problems like this.

4. What is the Zombie process?Zombie seems like the name got inspiration from the famous movie isn't it?
So far by now what we know that a process reap its child. Some time a process forgets to reap its child. After completing the assign task child releases all the resources which it was using but keeps the ID. As every process have a unique ID and when the parent reap its child it also relese the ID which the child was holding so that other new process can use this ID.
This cycle of IDs keep going on. Process releases the ID on termination and new comers gain it.
Coming back to the topic the child do not release the ID but resources now the OS can't kill this process as it don't have any resources according to OS it is already dead. How can an OS kill the already dead process.
But it is dangerous as it is holding the ID and of processes keep holding IDs like this we may get Shortage of IDs for new process so these kind of process which are not holding the resources but ID and we can't kill them because they are already dead are known as Zombies.

Video lecture on the topic Process termination in Hindi

Thursday, 19 March 2020

Process Creation and Child Process in Operating System


Process Creation and Child Process in Operating System

Operating system is also responsible for creating the processes.

In this lecture we have discussed about how a child process get created and what is the all life cycle of child process.

So first of all it is important to know that a process may or may not create a child process.
If a process create a child process or more than one child processes.

Those child processes will use the resources or ask for the resources to the parent process and parent process will provide the resource to child process.

Parent process also have the authority to limit the usage of resources by child process or the child may ask for all the resources which a parent have.

A child have also authority to create further more childs.

Parent and child process can communicate with each other as well because they share the same memory space.

Saturday, 14 March 2020

Context Switching in Operating System

Context Switching in Operating system

Context Switching or Process Switching in OS is one of the simplest topic and concept but when we try to make it more simple some time we forget to mention the most important and intresting things which happens in the Context switching.

This video of Operating system tutorials in hindi urdu is the lecture which clears the concept step by step in easy manner. 

Operating System Process states


Process States in Operating System

A process pass through lots of different stages in its life. To understand the working of Operating System it is important to understand the life cycle of process.

This topic will clear you concept about the process life cycle.

What is Process Control Block (PCB)? in Operating System


Process Control Block(PCB) in Operating System 

It is one of the most important topic in Operating System lots of the topics or say the advance topics of Operating system depends heavily on the conecpt of PCB in OS.

In the series of Operating System tutorials in hindi urdu we have just covered the topic of  PCB in Operating system as well I hope listening to this topic will clear your concepts.

To understand this topic in more better way I would recommend you to watch our lecture on the topic  How a program becomes process 

Friday, 6 March 2020

Types of Schedulers in OS | Long term, Medium term and Short term scheduler in Operating System



Scheduling Algorithm

To understand this topic in a better way I must recommend you go through once from our last lecture which was about Process Scheduling in Operating System so you may better understand the concept.
The processes wait into the different queues to get the process i.e. Job Queue, Ready Queue and Wait Queue.
This is the responsibility of algorithm to get to check which process should be assigned to processor.
You might be thinking there is nothing like responsibility here just let the process use the process number wise that is why they are already in the queue.

NO! NO! A BIG NO!

Suppose there is a queue of vehicles in the traffic jam and you have authority or say a kind of power by which you can make any vehicle to go first or last. Why wouldn’t you allow an ambulance to go first from that jam by using your powers or say authority.
The same case happens in the process queue some process come with emergency or say they want to get processor on priority basis (There are different cases for which a process wants to get processor on priority basis.)

This is the job of the scheduler algorithm to check which process should get the processor on priority basis that is why the scheduling algorithms are important.

We know we have three different queues Job Queue, Ready Queue and Wait Queue so we have three kind of scheduling algorithms as well.
·         Long Term Scheduler
·         Short Term Scheduler
·         Medium Term Scheduler

Long Term Scheduler:  This is responsible for managing the process in the job queue which is in the secondary memory.

Short Term Scheduler:  This is responsible for managing the process in the ready queue which is in the main memory.
softwareengineering,mysoftwarenotes.com,mysoftwarenotes,long term scheduler,short term scheduler,long term scheduler vs short term scheduler,medium term scheduler,types of scheduling algorithms,operating system,os,operating system tutorial,operating system hindi,long term scheduler in hindi,long term scheduler in os in hindi,long term scheduler diagram,cpu scheduler,explain long term scheduler,cpu os

Medium Term Scheduler:  This is not responsible for managing the process in the waiting queue as your thinking.
Why it is not responsible for waiting queue? Process have different states through which it passes in the whole life one out of theme is waiting state when the process is waiting for the I/O operation. After getting the I/O operating it get backs into the ready state that means eventually it will be managed by the short-term scheduler.

Medium Term scheduler is responsible to keep things in the smooth flow. Smooth by keeping they ways of other process clear.
But who block the ways?
Some time a process resides into the main memory and do nothing other than reserving resources short term scheduler swipe it out of the main memory and make space for other process. In some cases a low priority process use more memory in the main memory so to make space for priority basis process this algorithm swipe out that low priority process.

Softwareengineering,Operating System,mysoftwarenotes,mysoftwarenotes.com,process scheduling in operating system,process scheduling,process scheduling algorithms in operating system,process scheduling queues in operating system,process scheduling queues,process scheduling queues in operating system in hindi,ready queue,waiting queue theory,ready queue in operating system,ready queue and various i/o device queues,short term scheduler in operating system,os in hindi


Thursday, 5 March 2020

Process Scheduling and Schedulling queues in Operating System

Process Scheduling

B
efore directly jumping into the concepts and definitions of process scheduling I would like to make a base so you can understand the concepts the way one never forgets.
Suppose you are living in the joint family system and you have only landline telephone in your home. No one have personal phone (Mobile) so when ever someone want to make call uses the only landline phone.

Now if one family member wants to make a call He will go and simply make the call but what if more than one family member wants to make the call at the same time?
Answer is simple, the one who think to make the call first will make the call and the 2nd one will wait for the turn while 2nd one is waiting and the 3rd family member also want to make call He will go and wait for his turn which is on 3rdnumber.

What the 2nd and 3rd member did?
They schedule themselves into the queue and start waiting for their turn.
Same thing happens in the Operating System. Operating system have limited number of resources (Processer in this case) same as you have only phone in your home. Now if more than one process wants to use that processer, they will make queue and wait for their turn.
But like you and your family members the processes are not smart enough to make their queue by themselves so OS (Operating System) takes the responsibility to do this.
Operating Systems always use algorithms to perform such kind of tasks, Here Operating system use the scheduling algorithms.

Scheduling Algorithms: responsible for scheduling the process and assigning the process to processor on the turn or may be priority basis (How priority basis we will cover it soon keep reading)

Scheduling Queues: The places where the processes wait to get the resources are known as scheduling queues.

We have 3 different kind of scheduling queues. Why?
Because there is not only one process which will wait not only two but many. We cannot accommodate all the processes into the main memory because the main memory is always small in the amount.
We make a queue of process into the main memory the size of queue depends upon how much space we have into the main memory and we make another queue of remaining processes into the secondary memory so

Job Queue:  The queue of process that we will made in the secondary memory will be the job queue.

Ready Queue: The queue which we will made in the main memory will be the ready queue.

Where is the 3rd one? We said, “we have 3 different kind of queues”. The 3rd one is the waiting queue. The names tell its purpose clearly the process which are in waiting state waits in this queue but wait for what?
Process goes through different states in their life, one of them is waiting state where the wait for some I/O Operations.
Don’t forget to check out Process States lecture

The process waiting for the I/O Operating get settles into the queue.

Waiting Queue:  The queue where process wait for the I/O operations known as the waiting queue.
The waiting queue is always in the secondary memory as we don’t have enough space to accommodate large amount of process into the main memory.

Saturday, 29 February 2020

Process in Operating System | How Program becomes process | Heap | Stack | Program Counter

Concept of process, program counter, heap, stack and data section in OS (Operating System)

Program in Operating system:  

Set of instructions to perform specific task is called program. Program is a passive entity. It contains all the logics and data to perfrom any task.

Process in Operating system: 

When a program executes to perform the task it becomes the process. Process needs some kind of data which was writen in the instruction of the program to perform any task. 

Attributes of the Process:

To save that data process have attributes or I say pockets where it saves the data.
The names and working of the attributes is as following:
Program Counter:  
It saves the next instruction which will executes after the instruction currently being executed.

Stack: You might be familier with the concept of varriable if you have programming experiance. When you make a program you declare some local varriables.
When your program will become the process those local varriable will be placed in the stack.

Data Section: What about the global varriables? which you made in your program those all gona stay here.

Heap: So heap is referd to the dynamic memory allocation.

What is Dynamic Memory allocation?
Let me answer it with a scenario. suppose you code a program with an array of size 4 you run the program and start giving data to array as input but suddenly you realise that you have few more reamaing values and array is not enough to accomudate all.

Now the one option is stop the program and increase the size of the array and the other option is increase the size at run time.
When you will increase the size of array at run time it will demand the memory in the system as well so you will provide the memory at run time.
This memory allocation at the run time is known as dynamic memory allocation.

How someone can increase the size of array at run time?
You must be thingking like this, You should think but let me tell you we have some features available which can provide the more memory to your program at run time you can implement those features in C++.
in case if you are intrested in learning those funtion let me give you himt.
Google the concept of malloc() Function in which the m = memory and alloc = allocation .
I must refer you to this article for the learning of malloc.

Example:
SoftwareEngineering, mysoftwarenotes.com, mysoftwarenotes, OS, operatingsystem, Operating System,operating system notes,process, process attributes,process in operating system,process states, process in operating system in hindi,process in operating system in urdu,operating system process management, operating system process creation,
This is a simple C++ program with a function which returns the sum of 2 global varriables.
When we run this program, It will become the process there The global varriables of the program will go to the data section.

Local varriable of the program i.e sum  will go to the stack. and program counter will keep trace of the lines of these instructions that which one line is currently being executed and which one is the next.


Tuesday, 25 February 2020

What is the difference between user and kernel modes in operating system

User Mode and Kernel Mode difference in OS | Operating System

User Mode: 

If you are runing an application program so operating system is serving you in the user mode and the bit is 0. Bit mode values always switch between 0 and 1 it is a kind of signal if the bit mode is 1 that means the Operating system is in user mode. 

Kernel Mode: 

If you make some kind of demand being a user, that demands needs the hardware resources so the OS will switch to the kernel mode because the kernel mode is the only place where using OS's kernel we can access the hardware. 
While switching to the kernel mode operating system switch the bit mode to the 0.

Image we use to show the concept is :
user mode and kernel mode,kernel mode,user mode,user mode vs kernel mode,user mode and kernel mode difference,user mode and kernel mode in os,user mode in operating system

Wednesday, 19 February 2020

Multiprogramming vs Multitasking Operating System | Operating System | Hindi / Urdu



Multi-programming vs Multitasking Operating System

Setting base to concept. . .

  • In OS there are multiple processes waiting for getting CPU.
  • They want to get CPU to get executed.
  • These process are also known as jobs so don’t get confused if someone use word job instead of process.
  • Because a process is going to perform job while getting executed so say it a process or job or use these words interchangeably.
  • Coming back to topic, now there are lots of processes waiting for getting CPU, but the main memory is so small so all the process can’t get the space enough to sit and wait there so they wait in a place named job pool.

Multi-programming OS

  • CPU get one job out of the pool and start executing it.
  • Now between the execution there are 2 case look what 
  • CASE 1: CPU will get the job and execute it until it finish. 
  • CASE 2: CPU will be keep executing the job until the JOB itself ask the CPU to wait, as I am going for some I/O operating. 
  • When the job go for I/O operation, What CPU will do? 
  • It will no sit idle; it will choose some other job and Execute till the old one come back. 
  • Switching from one job to other is known as Context switching.

Multitasking OS

  • Multitasking means working on more than one task at a time means you are using computer and listening song also searching some thing on internet using browser and making word file that’s your assignment.
  • This is you are doing multitasking it seems like all the task are happening in the same time. 
  • Its not all the task happening at the same time it’s the processor switching between the different tasks in so speedy manners you think that they are happening at the same time. 
  • Lets go on the next slide to see how it happens behind the scene.
  • Multitasking is also using the concept of context switching but with the concept of time sharing. 
  • You know what is context switching, but what is time sharing? 
  • Time sharing is the CPU share the time between process, But how?  
  • The CPU let say decides it will give one second to each job, so what it will do… 
  • It will pick a job execute it for one second and then get for the next job without taking care if the job is completed or not. 
  • It will give time equally to all and come back to non-completed jobs in the next cycle.

Preemptive and Non-Preemptive

Preemptive is when CPU give all the time to process to complete the task and then move on towards the next process.

Non-Preemptive when CPU use the time slice and give equal time to each job no matter if the job finishes or not in the time. 

Download PDF Slides

Saturday, 15 February 2020

What is a Kernel in OS? What are the types of Kernel?

What is Kernel in Operating System and What are types of Kernel

This video is to clear the concept of kernel with daily life examples.

To download the slides used in the lecture click the button below


Thursday, 6 February 2020

Interrupt in Operating system | interrupt handler | interrupt vector in Operating System



Concept of interrupts, interrupt Handler and Interrupt vector in OS | With Examples

The concept of Interrupts, Interrupt handler and interrupt vector is not difficult but our mind always understand better when things relate to something what is happening in our daily life. These concepts are about the things which happens some where in the background of Operating system we hardly found them relate-able to some real life example.I try to relate them with the things that happens in front of your eyes.This video will clear your concepts about✔What is Interrupt?✔What is Interrupt Vector?✔What is Interrupt handler?

What is interrupt?

Interrupt means stop the activity, In OS interrupt means the same it is some kind of signal which stop the activity which is currently happening to perform some other important task.

What is interrupt handler?

Interrupt handler means when you handle the interrupt in it usually when the interrupt occurs control jump toward the interrupt handler and perform the required task. In the response of interrupt the handle contains the block of code to execute.

What is interrupt vector?

Vector is a kind of direction remember the high school physics where we used to study two types of quantities Scalar and Vector?
Scalar was the quantity without direction and the Vector was with direction the same thing is here.
Interrupt vector is the direction of the interrupt, it tells where is the block of code which is required to execute to handle the interrupt. 

Recommended to watch the video for better understanding

Download the PDF version of the slides here

Monday, 3 February 2020

operating system functions | operating system tutorials | Free Download



What is Operating system?
Its a bridge between the user and hardware of the system, It will manage the hardware resources utilizes them properly to facilitate you in your needs.

It work as a bridge between you and computer hardware.
If you are standing at one side of the bridge hardware of computer is at the other side of the bridge the bridge going to support both sides.

You can't run thing over computer directly, its OS which provide you platform over the hardware to run the required application to perform specific task.

Its is the most simple lecture about the OS sill if you feel need to download the slides here is the link given below.