-
Notifications
You must be signed in to change notification settings - Fork 0
/
globals.js
146 lines (106 loc) · 3.3 KB
/
globals.js
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
/* ------------
Globals.js
Global CONSTANTS and _Variables.
(Global over both the OS and Hardware Simulation / Host.)
This code references page numbers in the text book:
Operating System Concepts 8th edition by Silberschatz, Galvin, and Gagne. ISBN 978-0-470-12872-5
------------ */
//
// Global CONSTANTS
//
var APP_NAME = "EV-OS"; // 'cause I was at a loss for a better name.
var APP_VERSION = "0.05"; // What did you expect?
var CPU_CLOCK_INTERVAL = 50; // This is in ms, or milliseconds, so 1000 = 1 second.
var TIMER_IRQ = 0; // Pages 23 (timer), 9 (interrupts), and 561 (interrupt priority).
// NOTE: The timer is different from hardware/host clock pulses. Don't confuse these.
var KEYBOARD_IRQ = 1;
var SYSCALL_IRQ = 2;
var SINGLESTEP_IRQ = 3;
var END_IRQ = 4; // end process normally
var KILL_IRQ = 5; // end process abnormally
var CONTEXTSWITCH_IRQ = 6;
var FILESYSTEM_IRQ = 7;
// Process Statuses
var RUNNING = 'running';
var READY = 'ready';
var LOADED = 'loaded';
var ONDISK = 'disk';
var SWAP = '$WAP'; // invalid filename for users to create / delete...but let them read it!
// Scheduling Algorithm Constants
var ROUND_ROBIN = 'rr';
var FCFS = 'fcfs';
var PRIORITY = 'priority';
// Queues and lists for CPU scheduling
var ResidentList = [];
var ReadyQueue = [];
var MEMORY_SIZE = 768;
// Fixed Size Memory Allocation
var PARTITION_SIZE = 256;
var PARTITION_1 = {
base: 0,
limit: PARTITION_SIZE - 1,
avail: true
};
var PARTITION_2 = {
base: PARTITION_1.base + PARTITION_SIZE,
limit: PARTITION_1.limit + PARTITION_SIZE,
avail: true
};
var PARTITION_3 = {
base: PARTITION_2.base + PARTITION_SIZE,
limit: PARTITION_2.limit + PARTITION_SIZE,
avail: true
};
// each process on disk gets this
var DISK_PARTITION = {
base: '--',
limit: '--',
avail: true // this will always be true
};
// File system sizes
var TRACKS = 4;
var SECTORS = 8;
var BLOCKS = 8;
var BLOCK_SIZE = 64;
// operations to implement in filesystem API (pass in the isr)
var READ = 'read';
var WRITE = 'write';
var CREATE = 'create';
var DELETE = 'delete';
var FORMAT = 'format';
var LIST = 'ls';
var MAX_FILENAME = 30; // completely arbitrary
//
// Global Variables
//
var _CPU = null;
var scheduler = null;
var _Memory = null;
var _Disk = null;
var _OSclock = 0; // Page 23.
var _Mode = 0; // 0 = Kernel Mode, 1 = User Mode. See page 21.
var _SingleStep = false; //
var _Canvas = null; // Initialized in hostInit().
var _DrawingContext = null; // Initialized in hostInit().
var _DefaultFontFamily = "sans"; // Ignored, I think. The was just a place-holder in 2008, but the HTML canvas may have use for it.
var _DefaultFontSize = 13;
var _FontHeightMargin = 4; // Additional space added to font size when advancing a line.
// Default the OS trace to be on.
var _Trace = true;
// OS queues
var _KernelInterruptQueue = null;
var _KernelBuffers = null;
var _KernelInputQueue = null;
// Standard input and output
var _StdIn = null;
var _StdOut = null;
// UI
var _Console = null;
var _OsShell = null;
// At least this OS is not trying to kill you. (Yet.)
var _SarcasticMode = false;
// Global Device Driver Objects - page 12
var krnKeyboardDriver = null;
var krnFileSystemDriver = null;
// For testing...
var _GLaDOS = null;