Practice Questions for Exam - System Programming, Assignment | CS 241, Assignments of Computer Science

Material Type: Assignment; Professor: Gupta; Class: System Programming; Subject: Computer Science; University: University of Illinois - Urbana-Champaign; Term: Fall 2008;

Typology: Assignments

Pre 2010

Uploaded on 03/10/2009

koofers-user-w63
koofers-user-w63 🇺🇸

10 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Practice Question 1:
In a system using an inode-based filing system, each inode contains 10 direct pointers, 1 single-indirect,
1 double-indirect , and 1 triple indirect.
Part A:
If each disk block was 8 KB and each pointer was 16 bytes, how many i-nodes would need to be created
to write a new, 89 KB file?
Part B:
In the same system as [Part A], how many blocks would need to be used to write that new, 89 KB file?
(Include all blocks, including those of i-nodes.)
Part C:
In a different system, the size of a disk pointer is 32 bytes. If a file used exactly 9 direct pointers and
nothing more to store the contents of a 144 KB large file, what is the size of each disk block?
Practice Question 2:
In Homework #3, you ran four different disk arm scheduling algorithms (FIFO, SSTF, SCAN, and C-SCAN)
and found that three of the algorithms resulted in the same access pattern (SSTF, SCAN, and C-SCAN)?
What situations will result in these algorithms all resulting in the same access patterns?
Practice Question 3:
The following two segments of code perform the exact same functionality:
for (i = 0; i < n; i++)
for (j = 0; j < m; j++)
for (k = 0; k < p; k++)
C[i][j] = C[i][j] + A[i][k] * B[k][j];
for (i = 0; i < n; i++)
for (k = 0; k < p; k++)
for (j = 0; j < m; j++)
C[i][j] = C[i][j] + A[i][k] * B[k][j];
Code Block A
Code Block B
However, while running the programs, you notice that [Code Block B] runs slightly faster. When doing
more experiments, you find the [Code Block B] runs significantly faster in memory-constrained
environments where the system often is paging out physical memory to disk.
What is the name of the principle causes the observed effects? Give a general definition of that
principle.
pf3

Partial preview of the text

Download Practice Questions for Exam - System Programming, Assignment | CS 241 and more Assignments Computer Science in PDF only on Docsity!

Practice Question 1:

In a system using an inode-based filing system, each inode contains 10 direct pointers, 1 single-indirect,

1 double-indirect , and 1 triple indirect.

Part A:

If each disk block was 8 KB and each pointer was 16 bytes, how many i-nodes would need to be created

to write a new, 89 KB file?

Part B:

In the same system as [Part A], how many blocks would need to be used to write that new, 89 KB file?

(Include all blocks, including those of i-nodes.)

Part C:

In a different system, the size of a disk pointer is 32 bytes. If a file used exactly 9 direct pointers and

nothing more to store the contents of a 144 KB large file, what is the size of each disk block?

Practice Question 2:

In Homework #3, you ran four different disk arm scheduling algorithms (FIFO, SSTF, SCAN, and C-SCAN)

and found that three of the algorithms resulted in the same access pattern (SSTF, SCAN, and C-SCAN)?

What situations will result in these algorithms all resulting in the same access patterns?

Practice Question 3:

The following two segments of code perform the exact same functionality:

for (i = 0; i < n; i++) for (j = 0; j < m; j++) for (k = 0; k < p; k++) C[i][j] = C[i][j] + A[i][k] * B[k][j];

for (i = 0; i < n; i++) for (k = 0; k < p; k++) for (j = 0; j < m; j++) C[i][j] = C[i][j] + A[i][k] * B[k][j];

Code Block A Code Block B

However, while running the programs, you notice that [Code Block B] runs slightly faster. When doing

more experiments, you find the [Code Block B] runs significantly faster in memory-constrained

environments where the system often is paging out physical memory to disk.

What is the name of the principle causes the observed effects? Give a general definition of that

principle.

I. C Programming

  1. What is the * operator? What does it do?
  2. What is the & operator? What does it do?
  3. What’s the difference between char c[80] and char *c? …what about when they’re used in sizeof()?
  4. What do common C functions do? How are they called? String Functions: strcpy(), strtok(), strlen(), strcmp() Binary Functions: memcmp(), memcpy(), memset() Memory Functions: malloc(), remalloc(), free() I/O Functions: printf(), fgets(), fgetc(), read(), write(), fread(), fwrite() Thread-related Functions: pthread_create(), pthread_join(), pthread_detacth() Semaphore-related Functions: sem_init(), sem_destroy(), sem_post(), sem_wait() … and others.
  5. What is NULL?
  6. Understand how to trace and write pointer code.
  7. What’s the difference between a stack and a heap variable? What about global and static variables? II. Operating Systems
  8. What is the difference between a function call and a system call?
  9. What is an example of a purely function call? What is an example of function call that is a thinly wrapped system call? Why does printf() not fit in either category?
  10. What is the difference between a process and a thread?
  11. How do a user-thread and a kernel-thread differ?
  12. What are the different states that a process may be in within in operating system?
  13. What is a zombie thread? What is an orphan thread?
  14. What are the return values of fork()?
  15. Why is fork() nearly always used in conjunction when an exec() call is going to be used?
  16. What parts of memory are retained when fork() is called? …when exec() is called?
  17. How do you abandon a thread? How do you kill it? How do you wait for it to finish?
  18. What does it mean for a function to be thread-safe? III. Synchronization
  19. When is synchronization needed?
  20. What is the difference between a semaphore and a mutex? Can you use mutexs in place of a semaphore?
  21. What is a critical section?
  22. What is deadlock? What are the four conditions of deadlock?
  23. How does semaphores and testandset() differ?
  24. What are algorithms learned in class to deal with synchronization?
  25. How do you define a POSIX semaphore in C? What are the two main function calls to use it? How to you clean up the memory associated with a semaphore? IV. Scheduling
  26. Why do processes need to be scheduled?
  27. How do you schedule with a FIFO policy? FCFS? SJF? Round robin?
  28. What does it mean for a scheduling algorithm to be preemptive?
  29. How does bounded wait apply to scheduling? What is starvation? What is the convey effect?
  30. What is response time? Turn-around time? What other metrics do we use?