Operating Systems Midterm (2026)
-
Data type
Recis defined below. What will be returned bysizeof(Rec)(64-bit machine)?typedef struct { char a; short b; char c; } *Rec;Answer: 8
-
Data type
Unionis defined below. What will be returned bysizeof(Union)(64-bit machine)?typedef union { int x; float y; char z[5]; } Union;Answer: 8
-
A pointer to an array called
parris defined below. What will be the result ofsizeof(parr)/sizeof(parr[0]).int arr[10]; int *parr = arr;Answer: 2
-
You have the following small program. What value will be retuned by the main function if the program is compiled with default flags?
#ifdef SUCCESS #define RET 0 #else #define RET 1 #endif int main() { return RET; }Answer: 1
-
What of the following global variables and functions are considered strong symbols by the linker?
- A.
void func(); - B.
void func() {} - C.
static void func() {} - D.
int x = 10; - E.
static int x = 10; - F.
extern int x;
Answer: B and D
- A.
-
Write a declaration of variable
p, which is a pointer to a function that returnsintand has one parameter of typeint.Answer:
int (*p)(int) -
Which is the slowest way of memory allocation?
- A. Stack memory
- B. Heap memory
- C. Static memory
Answer: B
-
What utility and system call is used to send a signal?
Answer: kill
-
What of the following signals cannot be handled in a user program?
- A. INT
- B. STOP
- C. CONT
Answer: B and C
-
What number will be printed by a child process if it is successfully created?
int main() { pid_t pid; pid = fork(); if (pid < 0) { printf("1"); } else if (pid == 0) { printf("2"); } else { printf("3"); } return 0; }Answer: 2
-
What will be printed by the following code?
int fd1, fd2, fd3; char c1, c2, c3; char *fname = argv[1]; fd1 = open(fname, O_RDONLY, 0); fd2 = open(fname, O_RDONLY, 0); fd3 = open(fname, O_RDONLY, 0); dup2(fd2, fd3); read(fd1, &c1, 1); read(fd2, &c2, 1); read(fd3, &c3, 1); printf("%c %c %c\n", c1, c2, c3);Answer:
a a b -
Write a command that will create a symbolic link called
mylinkfor file calledmyfile.Answer:
ln -s myfile mylink -
Write a permission mask to give all rights to everyone (read/write/execute permissions to user/group/other). It looks like
abc, where a/b/c are integer numbers.Answer: 777
-
Which file is the same as file
file1.txt?35153094 -rw-rw-r-- 2 andrewt andrewt 9 Jun 3 18:08 file1.txt 35153285 -rw-rw-r-- 1 andrewt andrewt 9 Jun 3 18:08 file2.txt 35140410 lrwxrwxrwx 1 andrewt andrewt 9 Jun 3 18:07 file3.txt -> file1.txt 35153094 -rw-rw-r-- 2 andrewt andrewt 9 Jun 3 18:08 file4.txt- A. file2
- B. file3
- C. file4
Answer: C