Skip to content

Instantly share code, notes, and snippets.

View marksurnin's full-sized avatar

Mark Surnin marksurnin

View GitHub Profile

Architectural design of lock implementation

Data structures

  • lock_t (enum)
  • blocked_queue (linked list of pcb_t) for threads waiting on a resource

Functions

  • lock_init(l) initializes lock l – no thread initially holds it
  • lock_acquire(l):
  • if no thread holds l: