Created
October 20, 2025 01:06
-
-
Save MuntashirAkon/c739e644d14d1bb81635d5e874b968cb to your computer and use it in GitHub Desktop.
For CS 153 course at UCR
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "types.h" | |
| #include "user.h" | |
| int PScheduler(void); | |
| int main(int argc, char *argv[]) { | |
| PScheduler(); | |
| exit(); | |
| } | |
| int PScheduler(void) { | |
| int pid; | |
| int i, j, k; | |
| setpriority(0); | |
| for (i = 0; i < 3; i++) { | |
| pid = fork(); | |
| if (pid > 0) { | |
| continue; | |
| } else if (pid == 0) { | |
| setpriority(30 - 10 * i); | |
| for (j = 0; j < 50000; j++) { | |
| asm("nop"); | |
| for (k = 0; k < 10000; k++) { | |
| asm("nop"); | |
| } | |
| } | |
| printf(1, "p i:%d t:%d\n", getpid(), uptime()); | |
| exit(); | |
| } else { | |
| printf(2, " \n Error fork() \n"); | |
| exit(); | |
| } | |
| } | |
| if (pid > 0) { | |
| for (i = 0; i < 3; i++) { | |
| wait(); | |
| } | |
| } | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment