Index of /perry/os/ostep/code/threads-sema

[ICO]NameLast modifiedSizeDescription

[PARENTDIR]Parent Directory  -  
[TXT]Makefile2019-05-30 13:37 597  
[TXT]README.md2019-05-30 13:37 1.8K 
[TXT]binary.c2019-05-30 13:37 708  
[TXT]dining_philosophers_deadlock.c2019-05-30 13:37 1.4K 
[TXT]dining_philosophers_deadlock_print.c2019-05-30 13:37 2.0K 
[TXT]dining_philosophers_no_deadlock.c2019-05-30 13:37 1.5K 
[TXT]dining_philosophers_no_deadlock_print.c2019-05-30 13:37 2.2K 
[TXT]join.c2019-05-30 13:37 592  
[TXT]producer_consumer_works.c2019-05-30 13:37 2.0K 
[TXT]rwlock.c2019-05-30 13:37 1.9K 
[TXT]throttle.c2019-05-30 13:37 908  
[TXT]zemaphore.c2019-05-30 13:37 532  
[TXT]zemaphore.h2019-05-30 13:37 728  
[TXT]README.html2021-05-31 14:59 5.7K 

ostep-code/threads-sema

Fork/Join

Simple example of the fork/join (i.e., waiting for a child) problem
using semaphores, found in join.c.

Run make to build the code; run join to test it. Fun!

prompt> make
prompt> ./join

Binary Semaphores (Locks)

Simple example of semaphores as locks (binary semaphores).
Code in binary.c.

Run make to build the code; run binary to test it. Fun!

prompt> make
prompt> ./binary

Producer/Consumer

Code for the working producer/consumer solution from the text,
found in producer_consumer.c.

Run make to build, and producer_consumer to test it.
The program takes a few different arguments:

prompt> make
prompt> ./producer_consumer 1 1000 1

The output should print each produced item once, and show which
consumer consumed each produced item.

Reader/Writer Locks

Code in rwlock.c. Build via make, run via rwlock.

Dining Philosophers

The dining philosophers example from the text is found herein, in a few
different forms:

Run make to build all of them with the highly primitive Makefile.

Zemaphores

Code in zemaphore.c. We bet you can figure out the rest. This is just
a small test of the Zemaphore with the fork/join problem.

Throttle

Bonus code that shows how semaphores can be used to throttle how
many different threads run through a certain bit of code at a time.
Code in throttle.c.