-->

My Blog

Latest blog

Simulate the SJF Non preemptive Scheduling Algorithms. Using this scheduling algorithm find the min & max waiting time.

 

#include<stdio.h>

int main()

{

int bt[20],p[20],wt[20],tat[20],i,j,n,total=0,pos,temp, maxWatingTime=0,

minWatingTime=0;

float avg_wt,avg_tat;

printf("Enter number of process:");

scanf("%d",&n);

printf("\nEnter Burst Time:\n");

for(i=0;i<n;i++)
{
printf("p%d:",i+1);
scanf("%d",&bt[i]);
p[i]=i+1;

}

//sorting of burst times

for(i=0;i<n;i++)

{

pos=i;

for(j=i+1;j<n;j++)

{

if(bt[j]<bt[pos])

pos=j;

}

temp=bt[i];

bt[i]=bt[pos];

bt[pos]=temp;

temp=p[i];

p[i]=p[pos];

p[pos]=temp;

}

wt[0]=0;

for(i=1;i<n;i++)

{

wt[i]=0;

for(j=0;j<i;j++)

wt[i]+=bt[j];

total+=wt[i];

}

avg_wt=(float)total/n;

total=0;

printf("\nProcess\t Burst Time \tWaiting Time\tTurnaround Time");

for(i=0;i<n;i++)

{

tat[i]=bt[i]+wt[i];

total+=tat[i];

printf("\np%d\t\t %d\t\t %d\t\t\t%d",p[i],bt[i],wt[i],tat[i]);

}

          avg_tat=(float)total/n;

printf("\n\nAverage Waiting Time=%f",avg_wt);

printf("\nAverage Turnaround Time=%f\n",avg_tat);

maxWatingTime = wt[0];

for(i=0;i<n;i++)

{

if(wt[i] > maxWatingTime)

{

maxWatingTime = wt[i];

}

if(wt[i] < maxWatingTime)

{

minWatingTime = wt[i];

}

}

printf("Maximum Wating Time : %d\n", maxWatingTime);

printf("Minimum Wating Time : %d\n", minWatingTime);

}


Output:

Operating Systems Quiz 



1. The systems which allows only one process execution at a time, are called

a) uniprogramming systems

b) uniprocessing systems

c) unitasking systems

d) none of the mentioned

2.  What is the ready state of a process?

a) when process is scheduled to run after some execution

b) when process is unable to run until some task has been completed

c) when process is using the CPU

d) none of the mentioned

3. A set of processes is deadlock if

a) each process is blocked and will remain so forever

b) each process is terminated

c) all processes are trying to kill each other

d) none of the mentioned

4. The address of the next instruction to be executed by the current process is

provided by the

a) CPU registers

b) Program counter

c) Process stack

d) Pipe

5. The processes that are residing in main memory and are ready and waiting to

execute are kept on a list called

a) job queue

b) ready queue

c) execution queue

d) process queue

6.  In priority scheduling algorithm

a) CPU is allocated to the process with highest priority

b) CPU is allocated to the process with lowest priority

c) Equal priority processes cannot be scheduled

d) none of the mentioned

7. The interval from the time of submission of a process to the time of completion

is termed as

a) waiting time

b) turnaround time

c) response time

d) throughput

8.  Response time is :

a) the total time taken from the submission time till the completion time

b) the total time taken from the submission time till the first response is produced

c) the total time taken from submission time till the response is output

d) none of the mentioned

9. A process is selected from the ______ queue by the ________ scheduler, to be

executed.

a) blocked, short term

b) wait, long term

c) ready, short term

d) ready, long term

10. In the following cases non – preemptive scheduling occurs :

a) When a process switches from the running state to the ready state

b) When a process goes from the running state to the waiting state

c) When a process switches from the waiting state to the ready state

d) All of the mentioned

11. There are 10 different processes running on a workstation. Idle processes are

waiting for an input event in the input queue. Busy processes are scheduled with

the Round-Robin timesharing method. Which out of the following quantum times

is the best value for small response times, if the processes have a short runtime,

e.g. less than 10ms?

a) tQ = 15ms

b) tQ = 40ms

c) tQ = 45ms

d) tQ = 50ms

12.  Which of the following algorithms tends to minimize the process flow time?

a) First come First served

b) Shortest Job First

c) Earliest Deadline First

d) Longest Job First

13. The most optimal scheduling algorithm is:

a) FCFS – First come First served

b) SJF – Shortest Job First

c) RR – Round Robin

d) None of the mentioned

14. Consider the following set of processes, the length of the CPU burst time given

in milliseconds :

Process Burst time

P1 6

P2 8

P3 7

P4 3

Assuming the above process is scheduled with the SJF scheduling algorithm:

a) the waiting time for process P1 is 3ms

b) The waiting time for process P1 is 0ms

c) The waiting time for process P1 is 16ms

d) The waiting time for process P1 is 9ms

15. One of the disadvantages of the priority scheduling algorithm is that :

a) it schedules in a very complex manner

b) its scheduling takes up a lot of time

c) it can lead to some low priority process waiting indefinitely for the CPU

d) none of the mentioned


Answer: 

1) a

2) b

3) a

4) b

5) b

6) a

7) b

8) b

9) c

10) b

11) a

12) b

13) b

14) a

15) c


#OperatingSystemQuiz

 Regex strength in javaScript







Expression: ^(?=.*[A-Z].*[A-Z])(?=.*[!@#$&*])(?=.*[0-9].*[0-9])(?=.*[a-z].*[a-z].*[a-z]).{8}$



   Explanation

^                                       Start anchor
(?=.*[A-Z].*[A-Z])          Ensure string has two uppercase letters.
(?=.*[!@#$&*])               Ensure string has one special case letter.
(?=.*[0-9].*[0-9])             Ensure string has two digits.
(?=.*[a-z].*[a-z].*[a-z])   Ensure string has three lowercase letters.
.{8}                                   Ensure string is of length 8.
$                                        End anchor.

How to Install Laravel 8 Project with React Js



  • Create a fresh Laravel Project:

composer create-project --prefer-dist laravel/laravel projectname

composer require laravel/ui


  • Generate Basic Scaffolding:

php artisan ui react //for react connect with laravel


  • Build All

npm install

npm run dev


  • If you need an authentication system on your website then run this command. otherwise, ignore

php artisan ui react --auth


  • React Router 6

npm add history react-router-dom@next

yarn add history react-router-dom@next


  • Working with react state, then you need to add those instruction in package.json

"babel":{

   "presets":[

  "@babel/preset-env",

  "@babel/preset-react"   

],

"plugins":[

"@babel/plugin-proposal-class-properties"

]

}


  • Controller Create

php artisan make:controller ControllerName

  • Create Model

php artisan make:model modelName

  • Migrate Table

php artisan migrate

  • If needed to change any Attribute then you can re-migrate the table using this command:

php artisan migarte:rollback




Follow the steps:


1. Copy HTTPS from the assignment git repository

   //Create a folder in your device and open your terminal, then type cd "folder name"--

2. git clone --bear
3. go to the personal GitHub repository and create a new repository, then copy the URL
4. cd project path
5. git push --mirror "Your personal repo URL"
6. done

If you want to change the origin(URL)

1. git remote -v //Check the origin
2. git remote set-url origin "Your own repo HTTPS"


Contact Me

Contact With Me

Contact me for a free consultation. Let's Work Together.

  • Chattogram, Bangladesh
  • +8801854992594
  • jubair.ahmed.junjun@gmail.com
  • www.jubairahmedjunjun.blogspot.com//