/cs251

Primary LanguageTeXGNU Affero General Public License v3.0AGPL-3.0

ECS 251 Presentation

Slides

pdf / LaTeX source

Video

Youtube Presentation Video

Quizzes

Quiz question 1

What goes wrong in the following program, if implemented in a Real Time Operating System on uniprocessor system?

  • A. Race condition
  • B. Dead lock
  • C. Starvation
  • D. Nothing wrong
class Lock {
  private:
    int value = FREE;
    Queue waiting;
  public:
    void acquire();
    void release();
}

Lock::acquire() {
    TCB *chosenTCB;

    disableInterrupts();
    if (value == BUSY) {
        waiting.add(runningThread);
        runningThread->state = WAITING;
        chosenTCB = readyList.remove();
        thread_switch(runningThread,
                      chosenTCB);
        runningThread->state = RUNNING;
        value = BUSY;
    } else {
        value = BUSY;
    }
    enableInterrupts();
}

Lock::release() {
    TCB *next;

    disableInterrupts();
    if (waiting.notEmpty()) {
        next = waiting.remove();
        next->state = READY;
        readyList.add(next);
        value = FREE;
    } else {
        value = FREE;
    }
    enableInterrupts();
}

Quiz question 2

Do uni- or multi-processor implementation of queuing locks discussed in this presentation use disabling interrupts / atomic instructions?

  • uniprocessor _______ disabling interrupts
  • uniprocessor _______ atomic instructions
  • multiprocessor _______ disabling interrupts
  • multiprocessor _______ atomic instructions

Choices for all blanks: "uses" / "does not use"

Quiz answers

Enter the following into bash

echo Q29ycmVjdCBhbnN3ZXIgZm9yIHF1ZXN0aW9uIDE6IEMKQ29ycmVjdCBhbnN3ZXIgZm9yIHF1ZXN0aW9uIDI6IHVzZXM7IGRvZXMgbm90IHVzZTsgdXNlczsgdXNlcwo= | base64 -d

Furthre reading

https://people.freebsd.org/~lstewart/articles/cpumemory.pdf