xv6 Kernel-17: sleep() and wakeup()

Поделиться
HTML-код
  • Опубликовано: 4 ноя 2024

Комментарии • 7

  • @FelipeBalbi
    @FelipeBalbi 2 года назад +2

    is acquire() also disabling interrupts?

  • @rizvanjawadruhan9056
    @rizvanjawadruhan9056 Год назад

    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.

  • @seanxu4637
    @seanxu4637 Год назад

    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?

    • @powlink6859
      @powlink6859 Год назад +1

      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.

    • @seanxu4637
      @seanxu4637 Год назад

      thanks for the explanation@@powlink6859

  • @morenokratter669
    @morenokratter669 2 года назад

    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?

    • @hhp3
      @hhp3  2 года назад +1

      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.