[-] קונבנציה לקבלת משתנים של הסקג'ולר
by cfirs - Tuesday, 14 June 2016 13:59:51
בעבודה נכתב:
"The relevant argument needs to be pushed onto the scheduler's stack during the initialization phase"
רק השאלה באיזה סדר?
PUSH T
PUSH K
OR
PUSH K
PUSH T
?
[-] Re: קונבנציה לקבלת משתנים של הסקג'ולר
by sadetsky - Wednesday, 15 June 2016 12:07:40
It should appear to the scheduler AS IF it had the following signature:
    void scheduler(unsigned int num_generations, unsigned int k);
where unsigned int is 4 bytes as usual.
[-] Re: קונבנציה לקבלת משתנים של הסקג'ולר
by elitsi - Thursday, 16 June 2016 14:02:58
something is unclear,

if the signature is "scheduler(unsigned int num_generations, unsigned int k)"
and we are calling it from the main is C - these two args will be pushed anyway,
so why should we push them again in the initialization ?

thanks
Re: קונבנציה לקבלת משתנים של הסקג'ולר
by sadetsky - Thursday, 16 June 2016 16:04:31
you do not call this function from man 
you call to "start_co_from_C" function  from C, that calls "do_resume" function
only after "do_resume" function executes "ret" instruction, the function of scheduler starts to run

so, these arguments are not pushed into the stack as if we execute "call scheduler", it works differently here
[-] Re: קונבנציה לקבלת משתנים של הסקג'ולר
by ncoh - Friday, 17 June 2016 10:33:19
when a function with two arguments foo(param1, param2) is being called from a C file, the assembly function will look like this:
foo:
push ebp
mov ebp, esp
...
mov esp, ebp
pop ebp
ret
so the stack will look like this:
 ....
param 2 
param 1
 return address
 old ebp
.... 
In this case, we will get acsess to the parameters using ebp+8 and ebp+12,
however, in our case, there is no return address and "ret" command, since jumping between functions is performed by the "resume".
So, my question is, how the scheduler should extract both parametrs? using only two pop commands? or maybe we need to assume that there is a retuen address in the stack "AS IF" it was called from a C file?

thanks
[-] Re: קונבנציה לקבלת משתנים של הסקג'ולר
by sadetsky - Sunday, 19 June 2016 00:29:51
you are right, there is no return address in the stack in this case
there is no function frame in this case, because we don't really call any function but use threads

so, don't use [ebp+8] notation
[-] Re: קונבנציה לקבלת משתנים של הסקג'ולר
by mezumans - Sunday, 19 June 2016 18:02:03
just to make it clear:

in scheduler:
ebp =num of generations
ebp+4 = k

in cell:
ebp=i
ebp+4= j  ?
thank you :)
Re: קונבנציה לקבלת משתנים של הסקג'ולר
by sadetsky - Sunday, 19 June 2016 22:47:20
you should do these calculations by yourself, it is part of the assignment execution