-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkernel.c
More file actions
59 lines (44 loc) · 1005 Bytes
/
Copy pathkernel.c
File metadata and controls
59 lines (44 loc) · 1005 Bytes
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
#include "./io.h"
#include "./multitasking.h"
#include "./irq.h"
#include "./isr.h"
void prockernel();
void proc_a();
int main()
{
// Clear the screen
clearscreen();
// Initialize our keyboard
initkeymap();
// Initialize interrupts
idt_install();
isrs_install();
irq_install();
// Start executing the kernel process
startkernel(prockernel);
return 0;
}
void prockernel()
{
// Create the user processes
createproc(proc_a, (void *) 0x10000);
// Count how many processes are ready to run
int userprocs = ready_process_count();
printf("Kernel Process Started\n");
// As long as there is 1 user process that is ready, yield to it so it can run
while(userprocs > 0)
{
// Yield to the user process
yield();
printf("Kernel Process Resumed\n");
// Count the remaining ready processes (if any)
userprocs = ready_process_count();
}
printf("Kernel Process Terminated\n");
}
// The user processes
void proc_a()
{
printf("User Process A Started\n");
exit();
}