Can the address of ticks variable change?I have printed it and saw that the address is different for each sleep call in the loop in sys_sleep function?How is this possible as the address of a global variable doesnt change?Also I reduced the number of cores to 1 when doing this test.
Thanks for the explanation, there is one question confused me a lot of time, is that why do you said the lock on the process (p->lock) will be released once we get into sched()? Could you please shed some light on that?
sched() function need p->lock before calling and in the implementation of sched() function it will check p->lock and release the lock after setting p->state to runnable.
Thanks for the explanation! I have 1 question: in the user.h file, sleep requires only an int as argument (sleep(int)). I have been explained from others that the argument holds the seconds to sleep. I tried it now several times with e. g. sleep(5) but it isn't working. Am I missing something?
In Linux/Unix, sleep() is passed the number of seconds. But in xv6, sleep() is passed the number of “ticks”, which is the number of clock ticks. 6 ticks will be a very, very short duration, so perhaps it is working, but too fast to be perceptible.
is acquire() also disabling interrupts?
Can the address of ticks variable change?I have printed it and saw that the address is different for each sleep call in the loop in sys_sleep function?How is this possible as the address of a global variable doesnt change?Also I reduced the number of cores to 1 when doing this test.
Thanks for the explanation, there is one question confused me a lot of time, is that why do you said the lock on the process (p->lock) will be released once we get into sched()? Could you please shed some light on that?
sched() function need p->lock before calling and in the implementation of sched() function it will check p->lock and release the lock after setting p->state to runnable.
thanks for the explanation@@powlink6859
Thanks for the explanation! I have 1 question: in the user.h file, sleep requires only an int as argument (sleep(int)). I have been explained from others that the argument holds the seconds to sleep. I tried it now several times with e. g. sleep(5) but it isn't working. Am I missing something?
In Linux/Unix, sleep() is passed the number of seconds. But in xv6, sleep() is passed the number of “ticks”, which is the number of clock ticks. 6 ticks will be a very, very short duration, so perhaps it is working, but too fast to be perceptible.