COMP 3000 2011 Week 9 Notes

From Soma-notes
Revision as of 21:32, 7 November 2011 by Sbrett (talk | contribs) (Created page with "Test Review (with Ann Fry) will go over Q5 before test 30 mins test Anil will have Q&A before the test Go over lab notes, and study questions 1) Q:Without errors, what does …")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Test Review (with Ann Fry)

will go over Q5 before test

30 mins test Anil will have Q&A before the test

Go over lab notes, and study questions

1) Q:Without errors, what does the execve system call return? A:execve doesn't return on success because process is replaced. (Found in man page of execve)

2) Q:Can a process modify its argument variables? Environment variables? A:Yes, Yes. Regular variables defined in process address space by the kernel & made accessible by libc Kernel copies the args of execve into the top of memory of the new program image (running in the old process)

3) Q:Who calls a signal handler? A:The kernel. Kernel emits the signal which is caught by the processes handler, so essentially the kernel calls the handler "machine generated error messages handled by the kerenl are sent via signals eg.(divide by zero & seg fault) Kernel calls the signal dispatcher in the process that calls the actual handler"

4) Q:If a parent and child process start printing "Parent\n" and "Child\n" to standard out, what will be the order of the output? A:Order is indeterminate (printing 2 words continuously). The scheduler determines how they are interleaved, either could go first.

5) Q:In race-demo, why does the consumer sometimes finish before the producer has done hardly anything? A:*dont worry for test* We will get it before next class

6) Q:What does pthread_join() do? A:Blocks calling thread until the specified thread id terminates (Ann posted a link in the answer key of Lab4 with mutex tutorial)

7) Q:How is argc calculated? Note that argc is not specified by execve! A:Calculated by libc in a process before main starts. # of args are counted by walking argv

8) Q:What parts of the kernel would you need to re-implement in userspace in order to simulate a loopback mount? A:Re-implemeting the file system (ext4) in userspace - then you can parse the file system image. WHY? It's a weird data structure, you can parse the file system image just like any file, you just can't use "file" operations because those are implemented in the kernel, but you could simulate them even by copying the kernel code into userspace.

9) Q:Why are sparse files tricky to copy? A:When you read them they do not look sparse. Scenario 1: trasferrring between file systems types, must allocate memory for entire file.

10) Q:What is the relationship between lost+found and fsck? A:If an improper shutdown, Linux throws all potentially corrupt files into lost+found directory for that partition fsck is used for disk recovery. fsck will go into lost+found directory and try to recover files