Project

General

Profile

syscall-user-library-hacked.txt

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

 
1

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

    
5
To apply the patch :
6

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

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

    
11
3. Go to src/userprog and run make clean
12

    
13
4. Run make or make check
14

    
15

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

    
18

    
19
# Riza's explanation:
20

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

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