Project

General

Profile

Bug #39 » syscall-user-library-hacked.txt

patch explanation - Riza Suminto, 08/26/2014 05:01 PM

 

This is a patch for system call user library. By using this patch, you
should be able to run pintos project 2 on linux.cs and CSIL machines.

To apply the patch :

1. Backup the original src/lib/user/syscall.c code

2. Replace that syscall.c with syscall-hacked.c (inside p2 guideline folder)

3. Go to src/userprog and run make clean

4. Run make or make check


If you still see any problem, please let us know.


# Riza's explanation:

What I do in syscall.c is to make sure that userprogram sets up the
argument stack correctly when passing it to syscall handler. When I did
some experiment that adds the argument by 1, it somehow setups the stack
correctly (but not with the original value), I feel like this can be fixed
by copying the argument value to a local variable inside the syscall
function, and then passing it to syscall handler via asm command. But my
previous attempt was failed. I think it is because of compiler optimization
that didn't copy the argument value to local variable, but directly passing
it to asm command (the local variable itself is not used for any
calculation, just temporary container). So I make it a little bit
complicated by wrapping it into a static struct and somehow it success and
set the stack correctly.

I have test it on linux.cs, cicero.cs, machoke.cs (one of CSIL machines),
and my own laptop. The solution passed all the tests with this
modification.
(2-2/2)