Project 1 Solutions

 

Total – 50 points

 

 

Write-up – 15 points

 

1.      What is "asmlinkage" as it occurs in the Linux kernel source, what does it do (give a short description)?

 

Asmlinkage is a macro that tells the compiler to look on the stack for parameters instead of looking in registers.

 

2.      gotos are generally considered bad programming style, but these are used frequently in the Linux kernel, why could this be?  This is a thinking question, so justification is more important than your answer.

 

They can be more efficient and can produce code that is easier to read.

 

3.      What is the difference between the "clone" and "fork" system calls?

 

Clone lets the child process share some of its memory space with the parent process while fork gives the child process a completely separate memory space.

 

4.      How could you extend your shell to support multiple simultaneous processes (foreground and background...)?

 

Don’t make the parent process wait for the child process to finish.

 

5.      How long does your new system call take (time it using gettimeofday and give an approximate answer)?  Explain your timing methodology.

 

Answers varied because people varied the way they timed their function. As long as you explained what you did and got a reasonable answer (something in microseconds), you got credit.

 

1.      Describe how you found the information needed to complete this project. Did it have the information you needed? Did you consult with any humans? If so, what did you try first and who did you consult with?

 

Any answer.

 

2.      Explain the calling sequence that makes your system call work. First, a user program calls <.....>. Then, <.....> calls <.....>. ... and so on. You can explain this using either text or a rough (less than 15 minutes) diagram.

 

1.      First, a user program calls a syscall function: syscall(__NR_execcounts, …).

2.      The syscall function causes an interrupt.

3.      The process finds the syscall indexed at __NR_execcounts in the interrupt table in entry.S.

4.      The process finds the actual implementation of that syscall and runs the code.

 

3.      Why do you think the designers of Linux implemented system calls the way they did? What were they trying to achieve? What were they trying to avoid?

 

They were probably trying to make the OS very secure (minimize what the user space program has access to) and efficient (fast jump table implementation). You needed to mention at least one of these).

 

4.      Give (in 1-2 sentences) an alternative idea for implementing system calls. State one way your idea would be better or worse than the way it is currently done.

 

Any reasonable answer that you put a little thought into.

 

Shell – 15 points

 

System call – 15 points

 

System call documentation – 5 points