View on GitHub

Computer Architecture and Operating Systems

Course taught at Faculty of Computer Science of Higher School of Economics

Operating Systems Midterm (2026)

  1. Data type Rec is defined below. What will be returned by sizeof(Rec) (64-bit machine)?

    typedef struct {
      char a;
      short b;
      char c;
    } *Rec;
    

    Answer: 8

  2. Data type Union is defined below. What will be returned by sizeof(Union) (64-bit machine)?

    typedef union {
      int x;
      float y;
      char z[5];
    } Union;
    

    Answer: 8

  3. A pointer to an array called parr is defined below. What will be the result of sizeof(parr)/sizeof(parr[0]).

    int arr[10];
    int *parr = arr;
    

    Answer: 2

  4. 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

  5. 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

  6. Write a declaration of variable p, which is a pointer to a function that returns int and has one parameter of type int.

    Answer: int (*p)(int)

  7. Which is the slowest way of memory allocation?

    • A. Stack memory
    • B. Heap memory
    • C. Static memory

    Answer: B

  8. What utility and system call is used to send a signal?

    Answer: kill

  9. What of the following signals cannot be handled in a user program?

    • A. INT
    • B. STOP
    • C. CONT

    Answer: B and C

  10. 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

  11. 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

  12. Write a command that will create a symbolic link called mylink for file called myfile.

    Answer: ln -s myfile mylink

  13. 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

  14. 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