-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprocess.c
99 lines (80 loc) · 1.81 KB
/
process.c
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
/*
* =====================================================================================
*
* Filename: process.c
*
* Description:
*
* Version: 1.0
* Created: Monday 03 November 2014 06:10:42 IST
* Revision: none
* Compiler: gcc
*
* Author: YOUR NAME (),
* Organization:
*
* =====================================================================================
*/
#include <system.h>
#define MAX_TASKS 100
struct task_struct
{
int state;
// int pid;
// int priority;
int process_table_number;
// int exit_code;
/* int runtime;
int start_time;
int deadline;
*/
/* int start_stack;
int start_code,end_code;
int start_data,end_data;
int code_limit;
int data_limit;
*/
/* struct tss_struct task_state_segment;
struct inode* present;
struct inode* root;
struct file* files[];
*/
};
struct process_table
{
task_struct tasks[MAX_TASKS];
int scheduling_algo;
int pt_start;
int pt_end;
task_struct* current;
};
process_table PT;
PT->scheduling_algo=0;
PT->current = PT->tasks[1];
pt_start = 0;
pt_end = 1;
void schedule(){
int next;
if(PT -> scheduling_algo == 0){
for(int i=pt_start ;i <= pt_end; i++){
if((PT-> tasks[i])->state == READY)
{
PT -> state = RUNNING;
next = i;
break;
}
}
switch_to(next);
}
/* else if( PT -> scheduling_algo == 1) ........ */
}
/*void kill(nr){
task_struct* p = PT -> tasks[nr];
mm_free_block(p-> start_code);
p = NULL;
* free_space(p); */
/*
void exec(char* path){
f_inode* inode = get_inode(path);
int* free_block = first_free_block();
*/