Skip to main content

Posts

Showing posts from May, 2023

Assignment No:3

 Assignment No:3 Slot-I  i. Write an OS program to implement FCFS Disk Scheduling algorithm.  CODE: 👇 #include<stdio.h> #include<stdlib.h> void main() { int req[20],cpos,i,n,j,index,dir,temp,headmove=0,size=200; printf("\nEnter number of requests"); scanf("%d",&n); printf("\n Enter request "); for(i=0;i<n;i++) scanf("%d",&req[i]); printf("\nEnter curreent position"); scanf("%d",&cpos); for(i=0;i<n;i++)   {    headmove=headmove+abs(cpos-req[i]);    cpos=req[i];    }    printf("\nNumber of head movements=%d",headmove); } ii. Write an OS program to implement SSTF algorithm Disk Scheduling algorithm.  CODE: 👇 #include<stdio.h> #include<stdlib.h> int main() {  int req[20],cpos,i,n,headmove=0,index,count=0,min,d;  printf("Enter the number of requests\n");  scanf("%d",&n);  printf("Enter the sequence of requests\n");  for(i=0;i<n;i++)  scanf(...

Assignment No: 2

 Assignment No: 2 Slot-1  i. Write a program to simulate Sequential (Contiguous) file allocation method. Assume disk with n number of blocks. Give value of n as input. Write menu driver program with menu options as mentioned above and implement each option. CODE: 👇 #include<stdio.h> #include<stdlib.h> #include<string.h> #define SIZE 100 #define NEWNODE (struct direntry*)malloc(sizeof(struct direntry)) struct direntry { char fname[14]; int start,count; struct direntry *next; }  *dirst=NULL,  *dirend=NULL;  int bitvector[SIZE];    void main()  {  int ch1=0,i,j,k,n,flag;  char fname[14];  int rand();  struct direntry *t1, *t2;   for(i=0; i<SIZE;i++)    {     bitvector[i]=rand()%2;        }           while(1)  {      printf("\n\n1.Print  Bit Vector");      printf("\n2.Create File");     ...

Assignment No:1

Assignment No:1  Slot 1  I) Add the following functionalities in your program  a) Accept Available  b) Display Allocation, Max  c) Display the contents of need matrix  d) Display Available CODE: 👇 #include<stdio.h> #include<ctype.h>  int  avail[] = {3,3,2} ;       int max[][10] = { {7,5,3} ,{3,2,2},{9,0,2} ,{2,2,2},{4,3,3}};       int alloc[][10] = { {0,1,0} ,{2,0,0},{3,0,2} ,{2,1,1},{0,0,2}};              int need[10][10] ;           int m = 3 , n = 5 , i,j;           void  get_allocation_matrix(); void main()    {     get_allocation_matrix();    }       void get_allocation_matrix()       {           printf("\n Number of Resources of matrix have %d", m);       printf("\n Number of Processes of matrix have %d", n)...