File tree 8 files changed +37
-0
lines changed
8 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -132,6 +132,7 @@ int getTurnAroundTime(int pid);
132
132
int getWaitingTime (int pid );
133
133
int getCBT (int pid );
134
134
int customWait (int * procTimes );
135
+ int setQueue (int queueNumber );
135
136
136
137
// swtch.S
137
138
void swtch (struct context * * , struct context * );
Original file line number Diff line number Diff line change @@ -121,6 +121,7 @@ allocproc(void)
121
121
p -> sleeping_t = 0 ;
122
122
p -> runnable_t = 0 ;
123
123
p -> running_t = 0 ;
124
+ p -> queue = 0 ; // by default each process is in the 0 queue
124
125
125
126
p -> rr_remaining_t = QUANTUM ;
126
127
p -> priority = DEFAULT_PRIORITY ;
@@ -792,4 +793,18 @@ int customWait(int *procTimes)
792
793
// Wait for children to exit. (See wakeup1 call in proc_exit.)
793
794
sleep (curproc , & ptable .lock ); //DOC: wait-sleep
794
795
}
796
+ }
797
+
798
+ int setQueue (int queueNumber )
799
+ {
800
+ struct proc * curproc = myproc ();
801
+ if (queueNumber > 4 || queueNumber < 1 )
802
+ {
803
+ return -1 ;
804
+ }
805
+ else
806
+ {
807
+ curproc -> queue = queueNumber ;
808
+ return 0 ;
809
+ }
795
810
}
Original file line number Diff line number Diff line change @@ -60,6 +60,7 @@ struct proc
60
60
struct file * ofile [NOFILE ]; // Open files
61
61
struct inode * cwd ; // Current directory
62
62
char name [16 ]; // Process name (debugging)
63
+ int queue ; // Defines in which queue the process belongs
63
64
64
65
// stores how many times each of the syscalls has been called
65
66
int syscallsCount [NSYSCALLS ];
Original file line number Diff line number Diff line change @@ -108,6 +108,7 @@ extern int sys_getTurnAroundTime(void);
108
108
extern int sys_getWaitingTime (void );
109
109
extern int sys_getCBT (void );
110
110
extern int sys_customWait (void );
111
+ extern int sys_setQueue (void );
111
112
112
113
static int (* syscalls [])(void ) = {
113
114
[SYS_fork ] sys_fork ,
@@ -140,6 +141,7 @@ static int (*syscalls[])(void) = {
140
141
[SYS_getWaitingTime ] sys_getWaitingTime ,
141
142
[SYS_getCBT ] sys_getCBT ,
142
143
[SYS_customWait ] sys_customWait ,
144
+ [SYS_setQueue ] sys_setQueue ,
143
145
144
146
};
145
147
Original file line number Diff line number Diff line change 29
29
#define SYS_getWaitingTime 28
30
30
#define SYS_getCBT 29
31
31
#define SYS_customWait 30
32
+ #define SYS_setQueue 31
32
33
Original file line number Diff line number Diff line change @@ -171,4 +171,16 @@ int sys_customWait(void)
171
171
{
172
172
return customWait (procTimes );
173
173
}
174
+ }
175
+
176
+ int sys_setQueue (void )
177
+ {
178
+ int queueNumber ;
179
+ if (argint (0 , & queueNumber ) < 0 )
180
+ {
181
+ return -1 ;
182
+ }
183
+ else
184
+ return setQueue (queueNumber );
185
+
174
186
}
Original file line number Diff line number Diff line change @@ -32,6 +32,8 @@ int getTurnAroundTime(int pid);
32
32
int getWaitingTime (int pid );
33
33
int getCBT (int pid );
34
34
int customWait (int * procTimes );
35
+ int setQueue (int queueNumber );
36
+
35
37
36
38
// ulib.c
37
39
int stat (const char * , struct stat * );
Original file line number Diff line number Diff line change @@ -37,4 +37,7 @@ SYSCALL(changePolicy)
37
37
SYSCALL (getTurnAroundTime)
38
38
SYSCALL (getWaitingTime)
39
39
SYSCALL (getCBT)
40
+ int setQueue(int queueNumber);
40
41
SYSCALL (customWait)
42
+ SYSCALL (setQueue)
43
+
You can’t perform that action at this time.
0 commit comments