-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathscan.html
153 lines (138 loc) · 6.3 KB
/
scan.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SCAN</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<script src="./add_point.js"></script>
<script type="text/javascript" src="https://canvasjs.com/assets/script/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<div style="display: block;">
<h1 style="text-align: center;">SCAN</h1>
</head>
<body>
<div class="container">
<p>In SCAN algorithm the disk arm moves into a particular direction and services the requests coming in its path and after reaching the end of disk, it reverses its direction and again services the request arriving in its path. So, this algorithm works as an elevator and hence also known as elevator algorithm. As a result, the requests at the midrange are serviced more and those arriving behind the disk arm will have to wait.</p>
<ul>
<h3>Advantages:</h3>
<li>High throughput</li>
<li>Low variance of response time</li>
<li>Average response time</li>
</ul>
<ul>
<h3>Disadvantages:</h3>
<li>Long waiting time occurs for the cylinders which are just visited by the head</li>
<li>In SCAN the head moves till the end of the disk despite the absence of requests to be serviced</li>
</ul>
</div>
<div class="container">
<input type="text" id="text1" placeholder="enter order of request sequence : "></input>
<input type="button" id="button1" value="Add" onclick="add_element_to_array()"></input>
<input type="button" id="button2" value="Remove" onclick="remove_array()"></input><br> <br>
<input type="text" id="text2" placeholder="enter read/write head position : "></input><br>
<br>
<input type="submit" value="SUBMIT IT" onclick="myfun();" id="continue">
<p id="t2"></p>
</div>
<div id="chartContainer" style="max-width: 920px; margin: 0px auto; margin-left:40%;"></div>
<script>
var x = 0,p=1;
var array1 = Array();
var q=document.createElement("table");
q.setAttribute("id","mytable");
var chart = new CanvasJS.Chart("chartContainer", {
title: {
text: "Adding & Updating dataPoints"
},
axisX2: {
title: "Secondary X Axis",
},
axisY: {
reversed: true
},
data: [{
axisXType: "secondary",
type: "line",
dataPoints: []
}],
animationEnabled: false,
animationDuration: 2000
});
chart.render();
function add_element_to_array() {
array1[x] = document.getElementById("text1").value;
var row = q.insertRow(-1);
var cell1 = row.insertCell(0);
var cell2 = row.insertCell(1);
cell1.innerHTML = "process :"+p + " -->";
cell2.innerHTML = array1[x];
document.body.appendChild(q);
x++;
p++;
document.getElementById("text1").value =" ";
}
function remove_array()
{
array1.pop();
var x = document.getElementById("mytable").rows.length;
document.getElementById("mytable").deleteRow(x-1);
console.log(array1);
p--;
}
function myfun() {
console.log(array1);
const array = array1.map((i) => Number(i));
console.log(array);
var head = document.getElementById('text2').value;
var seek = 0;
var dis, cur;
var left = [];
var right = [];
var seq = [];
for (var i = 0; i < array.length; i++) {
if (array[i] < head) {
left.push(array[i]);
}
if (array[i] > head) {
right.push(array[i]);
}
}
left.sort(function(a, b) { return (a - b) });
right.sort(function(a, b) { return (a - b) });
console.log(left);
console.log(right);
seek = seek + Math.abs(199 - head);
var count = 0;
addPoint(head, count);
count++;
for (var i = 0; i < right.length; i++) {
cur = right[i];
addPoint(cur, count);
count++;
seq.push(cur);
head = cur;
}
if (head != 199) {
head = 199;
addPoint(199, count);
count++;
seq.push(head);
}
for (var i = left.length - 1; i >= 0; --i) {
cur = left[i];
addPoint(cur, count);
count++;
seq.push(cur);
head = cur;
}
seek = seek + Math.abs(199 - head);
document.getElementById("t2").innerHTML = "the number of movement for fcfs =" + seek;
console.log(seq);
}
</script>
</body>
</html>