Question

In: Computer Science

Write Algoritm , code and output. In C++ In Operating Systems , Simulate with a program...

Write Algoritm , code and output. In C++

In Operating Systems ,

Simulate with a program to schedule disk in seek optimization.

Solutions

Expert Solution

// C++ program to demonstrate

// FCFS Disk Scheduling algorithm

#include <bits/stdc++.h>

using namespace std;

int size = 8;

void FCFS(int arr[], int head)

{

    int seek_count = 0;

    int distance, cur_track;

    for (int i = 0; i < size; i++) {

        cur_track = arr[i];

        // calculate absolute distance

        distance = abs(cur_track - head);

        // increase the total count

        seek_count += distance;

        // accessed track is now new head

        head = cur_track;

    }

    cout << "Total number of seek operations = "

         << seek_count << endl;

    // Seek sequence would be the same

    // as request array sequence

    cout << "Seek Sequence is" << endl;

    for (int i = 0; i < size; i++) {

        cout << arr[i] << endl;

    }

}

// Driver code

int main()

{

    // request array

    int arr[size] = { 176, 79, 34, 60, 92, 11, 41, 114 };

    int head = 50;

    FCFS(arr, head);

    return 0;

}

Total number of seek operations = 510
Seek Sequence is
176
79
34
60
92
11
41
114

Note: Plzzz don' t give dislike.....Plzzz comment if u have any problem i will try to resolve it.......


Related Solutions

Write Algoritm , code and output. In Operating Systems , . Implement a program for page...
Write Algoritm , code and output. In Operating Systems , . Implement a program for page replacement using the following a.FIFO b.LRU c.OPTIMAL
Write Algoritm , code and output. In Operating Systems , 26. Implement a program to allocate...
Write Algoritm , code and output. In Operating Systems , 26. Implement a program to allocate memory by applying the following strategies.a .FIRST FIT b.BEST FIT c.WORST FIT
Write a program to simulate the Distributed Mutual Exclusion in ‘C’.
Write a program to simulate the Distributed Mutual Exclusion in ‘C’.
C++ program. Please explain how the code resulted in the output. The code and output is...
C++ program. Please explain how the code resulted in the output. The code and output is listed below. Code: #include <iostream> #include <string> using namespace std; int f(int& a, int b) {    int tmp = a;    a = b;    if (tmp == 0) { cout << tmp << ' ' << a << ' ' << b << endl; }    b = tmp;    return b;    return a; } int main() {    int a...
*****For C++ Program***** Overview For this assignment, write a program that uses functions to simulate a...
*****For C++ Program***** Overview For this assignment, write a program that uses functions to simulate a game of Craps. Craps is a game of chance where a player (the shooter) will roll 2 six-sided dice. The sum of the dice will determine whether the player (and anyone that has placed a bet) wins immediately, loses immediately, or if the game continues. If the sum of the first roll of the dice (known as the come-out roll) is equal to 7...
Using C++, write a code that this program always stores text file output into a text...
Using C++, write a code that this program always stores text file output into a text file named "clean.txt". -The program should read one character at a time from "someNumbers.txt", and do the following. -If it is a letter, print that letter to the screen, AND also store it in the text file. All letters should be converted to lowercase beforehand. -If it is a number, print that number to screen, but do NOT store it in the text file....
please write in c using linux or unix Write a program that will simulate non -...
please write in c using linux or unix Write a program that will simulate non - preemptive process scheduling algorithm: First Come – First Serve Your program should input the information necessary for the calculation of average turnaround time including: Time required for a job execution; Arrival time; The output of the program should include: starting and terminating time for each job, turnaround time for each job, average turnaround time. Step 1: generate the input data (totally 10 jobs) and...
Please write in C using linux or unix. Write a program that will simulate non -...
Please write in C using linux or unix. Write a program that will simulate non - preemptive process scheduling algorithm: First Come – First Serve Your program should input the information necessary for the calculation of average turnaround time including: Time required for a job execution; Arrival time; The output of the program should include: starting and terminating time for each job, turnaround time for each job, average turnaround time. Step 1: generate the input data (totally 10 jobs) and...
Write source code in C to simulate the contiguous file allocation with the following conditions: •...
Write source code in C to simulate the contiguous file allocation with the following conditions: • Prompt the user to ender the no of files • Enter the name of the file • Enter the Starting block number • Enter no of block occupied by the file i.Condition: No two files must have the same block(if the user enter the same block no present in the previous file prompt the user “Block already in use”) #include<stdio.h> #include<conio.h> struct {    ...
Write a c++ Program To simulate the messages sent by the various IoT devices, a text...
Write a c++ Program To simulate the messages sent by the various IoT devices, a text le called device data.txt is provided that contains a number of device messages sent, with each line representing a distinct message. Each message contains a device name, a status value and a Unix epoch value which are separated by commas. Your c++ program will read this le line by line. It will separate the message into device name, status value and epoch value and...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT