Showing posts with label Explain and Solve. Show all posts
Showing posts with label Explain and Solve. Show all posts

C++ Program (Source Code) for Priority Scheduling CPU Scheduling Algorithm

Priority Scheduling:

In operating systems, tasks that are queued to be processed go through different scheduling algorithms in different operating systems. Priority Scheduling is one of them.
Priority scheduling is like shortest job first except that the next job to process is selected not by the amount of time it will take, but by the priority of the job. So in this priority scheduling each job has a priority value associated with it. The task with shortest priority value gets preferred.


C++ Program (Source Code) for Round Robin (RR) CPU Scheduling Algorithm


Round Robin (RR):

In operating systems, tasks that are queued to be processed go through different scheduling algorithms in different operating systems. Round Robing or RR is one of them.
In round robin, like first come first served, the job or task that comes first, gets processed first, but not fully. Rather in round robin, a portion or segment of the task is completed at once, then the processor moves to the next task and then processes that same amount of task for this second task in hand and it continues. When a portion or segment of all tasks has been processed, the processor starts from the beginning of the task list again and continues to process a portion or segment of each remaining tasks. However in this way, as new task can be continuously added at the end of the task list, the processor might not come back to the head of the list sooner which might cause tasks to be waiting for much longer time ultimately resulting in halted situation.


C++ Program (Source Code) for Preemptive Shortest Job First (SJF) CPU Scheduling Algorithm

Shortest Job First:

In operating systems, tasks that are queued to be processed go through different scheduling algorithms in different operating systems. Shortest Job First or SJF is one of them. In shortest job first, literary, the smallest task among all the remaining tasks will get processed first.

However, I explained Shortest Job First (SJF) in my another post earlier and as many of my readers wanted to have the source code, here I am publishing the source code of the program. I am not currently explaining the source code, please try to play with it to understand it. I am removing comments intentionally.


C++ Program (Source Code) for First Come First Served (FCFS) CPU Scheduling Algorithm

First Come First Served (FCFS): 

In operating systems, tasks that are queued to be processed go through different scheduling algorithms in different operating systems. First Come First Served or FCFS is one of them.
In first come first served, literary, the task that comes first to be processed gets processed first, then the next one and this continues. This is a less preferable way of scheduling as any task can block the processor for infinite amount of time. Also as all tasks are given the same priority, more important tasks might be waiting too long to be processed.


Explain and Solve : Round Robin (RR) CPU Scheduling Algorithm in C++ with Explanation


If you haven't read/tried the earlier/other problems then click the links follow:

Round Robin CPU Scheduling Algorithm in C++ with Explanation: 

This method is quite same as the FCFS but the difference is the in this case the processor will not process the whole job (process) at a time. Instead, it will complete an amount of job (quantum) at a turn and then will go to the next process and so on. When all job has got a turn, it will again start from the first job and work for a quantum of time/cycle on each job and proceed. Now consider a CPU and also consider a list in which the processes are listed as follows,

Arrival
Process
Burst Time
0
1
3
1
2
2
2
3
1

Quantum = 2 Second

Explain and Solve : Priority Scheduling CPU Scheduling Algorithm in C++ with Explanation

If you haven't read/tried the earlier problems then click the links follow:


Priority Scheduling CPU Scheduling Algorithm in C++ with Explanation: 

This method is quite same as the SJF but the difference is that instead of choosing the next process to work on by the shortest burst time, CPU chooses the next process by the shortest priority value. Here, all the processes are given a priority value. The process with the shortest (The most shortest is 1) priority will be worked on first and so on. Now consider a CPU and also consider a list in which the processes are listed as follows,

Arrival
Process
Burst Time
Priority
0
1
3
2
1
2
2
1
2
3
1
3

Preemptive Shortest Job First (SJF) CPU Scheduling Algorithm in C++ with Explanation


If you haven't read/tried the earlier problems then click the links follow:



Preemptive Shortest Job First (SJF) CPU Scheduling Algorithm in C++ with Explanation

Preemptive Shortest Job First (SJF) CPU Scheduling Algorithm in C++ with Explanation:

Preemptive Shortest Job First (SJF) is a CPU scheduling algorithm in which the CPU, at any given time, looks for the job with the shortest burst time among the jobs in hand and starts processing it. In SJF the processor will not just pick the job that arrived first, rather will compare them based on their required CPU time and will pick the one which requires lowest amount of time.

Explain and Solve : First Come First Served (FCFS) CPU Scheduling Algorithm in C++ with Explanation

If you haven't read/tried the earlier problems then click the links follow:


First Come First Served (FCFS) CPU Scheduling Algorithm in C++ with Explanation: 

CPU gets a lot of processes to handle. The problem is shortening the waiting time for a process to reach CPU and get processed. Now consider a CPU and also consider a list in which the processes are listed as follows,
Arrival
Process
Burst Time
0
1
3
1
2
2
2
3
1

Here, Arrival is the time when the process has arrived the list, Process Number is used instead of the process name, and Burst Time is the amount of time required by the process from CPU. Well, as the unit of time you can take anything like nano-second, second, minute etc whatever. We consider it as second.


What are the three problems of economic organizations? How can the three problems of economic organization be solved in free and mixed economics?

Three Problems of Economic Organizations:

In every economy; economic organizations, irrespective of their type, have to face and solve three problems of economics. These three problems are as follows,

  1. What commodities are produced & in what quantities.
  2. How goods are produced.
  3. For whom goods are produced.

Description and solution to these problems in fee and mixed economies is given below.