Backlog Slip 12
Backlog Slip 12
#include <stdio.h>
#define MAX_FRAMES 10
#define MAX_REF 15
int main() {
int ref[MAX_REF] = {3, 4, 5, 6, 3, 4, 7, 3, 4, 5, 6, 7, 2, 4, 6}, n;
printf("Frames: "); scanf("%d", &n);
if (n <= 0 || n > MAX_FRAMES) return printf("Invalid frames!\n"), 1;
LRU(ref, MAX_REF, n);
}
Q2
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <dirent.h>
int main() {
char input[1024], *args[10];
while (printf("myshell$ "), fgets(input, sizeof(input), stdin)) {
input[strcspn(input, "\n")] = 0; int i = 0;
for (char *t = strtok(input, " "); t; t = strtok(NULL, " ")) args[i++] = t;
args[i] = NULL; if (!i || !strcmp(args[0], "exit")) break;
!strcmp(args[0], "list") ? list_command(args) : execute(args);
}
return 0;
}