Skip to content

Instantly share code, notes, and snippets.

@RSquaredSoftware
Created April 17, 2013 03:43
Show Gist options
  • Save RSquaredSoftware/5401628 to your computer and use it in GitHub Desktop.
Save RSquaredSoftware/5401628 to your computer and use it in GitHub Desktop.
./smokers
Smoker 5 with tobacco waiting to smoke
Smoker 4 with tobacco waiting to smoke
Smoker 3 with match waiting to smoke
Smoker 2 with match waiting to smoke
Smoker 1 with paper waiting to smoke
Smoker 0 with paper waiting to smoke
Agent 0 giving out tobacco
Smoker 3 with match received other items. Now smoking for the 1 time...
Smoker 3 with match done smoking
Agent 1 giving out match
Smoker 5 with tobacco received other items. Now smoking for the 1 time...
Smoker 5 with tobacco done smoking
Agent 2 giving out tobacco
Smoker 1 with paper received other items. Now smoking for the 1 time...
Smoker 5 with tobacco waiting to smoke
Smoker 1 with paper done smoking
Smoker 1 with paper waiting to smoke
Smoker 3 with match waiting to smoke
Agent 0 giving out tobacco
Smoker 2 with match received other items. Now smoking for the 1 time...
Smoker 2 with match done smoking
Smoker 2 with match waiting to smoke
Agent 0 giving out tobacco
Smoker 3 with match received other items. Now smoking for the 2 time...
Smoker 3 with match done smoking
Agent 2 giving out tobacco
Smoker 0 with paper received other items. Now smoking for the 1 time...
Smoker 3 with match waiting to smoke
Smoker 0 with paper done smoking
Agent 1 giving out match
Smoker 4 with tobacco received other items. Now smoking for the 1 time...
Smoker 4 with tobacco done smoking
Smoker 4 with tobacco waiting to smoke
Smoker 0 with paper waiting to smoke
Agent 2 giving out tobacco
Smoker 1 with paper received other items. Now smoking for the 2 time...
Smoker 1 with paper done smoking
Smoker 1 with paper waiting to smoke
Agent 0 giving out tobacco
Smoker 2 with match received other items. Now smoking for the 2 time...
Smoker 2 with match done smoking
Smoker 2 with match waiting to smoke
Agent 1 giving out match
Smoker 5 with tobacco received other items. Now smoking for the 2 time...
Smoker 5 with tobacco done smoking
Smoker 5 with tobacco waiting to smoke
Agent 2 giving out tobacco
Smoker 0 with paper received other items. Now smoking for the 2 time...
Smoker 0 with paper done smoking
Agent 2 giving out tobacco
Smoker 1 with paper received other items. Now smoking for the 3 time...
Smoker 0 with paper waiting to smoke
Smoker 1 with paper done smoking
Agent 0 giving out tobacco
Smoker 3 with match received other items. Now smoking for the 3 time...
Smoker 3 with match done smoking
Agent 1 giving out match
Smoker 4 with tobacco received other items. Now smoking for the 2 time...
Smoker 1 has smoked 3 times and is leaving
Smoker 3 has smoked 3 times and is leaving
Smoker 4 with tobacco done smoking
Agent 2 giving out tobacco
Smoker 0 with paper received other items. Now smoking for the 3 time...
Smoker 4 with tobacco waiting to smoke
Smoker 0 with paper done smoking
Agent 1 giving out match
Smoker 5 with tobacco received other items. Now smoking for the 3 time...
Smoker 0 has smoked 3 times and is leaving
Smoker 5 with tobacco done smoking
Agent 1 giving out match
Smoker 4 with tobacco received other items. Now smoking for the 3 time...
Smoker 5 has smoked 3 times and is leaving
Smoker 4 with tobacco done smoking
Agent 0 giving out tobacco
Smoker 2 with match received other items. Now smoking for the 3 time...
Smoker 4 has smoked 3 times and is leaving
Smoker 2 with match done smoking
Smoker 2 has smoked 3 times and is leaving
All threads stopped, exit success
server@server:/var/www/Spring-2013/OS/semaphores$ make clean; make
rm -f *.o *.exe smokers
gcc smokers.c -lrt -std=gnu99 -pthread -o smokers
smokers.c: In function ‘paperSmoker’:
smokers.c:47:9: warning: implicit declaration of function ‘usleep’ [-Wimplicit-function-declaration]
./smokers
Smoker 5 with tobacco waiting to smoke
Smoker 4 with tobacco waiting to smoke
Smoker 3 with match waiting to smoke
Smoker 2 with match waiting to smoke
Smoker 1 with paper waiting to smoke
Smoker 0 with paper waiting to smoke
Agent 1 giving out match
Smoker 5 with tobacco received other items. Now smoking for the 1 time...
Smoker 5 with tobacco done smoking
Agent 1 giving out match
Smoker 4 with tobacco received other items. Now smoking for the 1 time...
Smoker 5 with tobacco waiting to smoke
Smoker 4 with tobacco done smoking
Agent 1 giving out match
Smoker 5 with tobacco received other items. Now smoking for the 2 time...
Smoker 4 with tobacco waiting to smoke
Smoker 5 with tobacco done smoking
Agent 0 giving out tobacco
Smoker 3 with match received other items. Now smoking for the 1 time...
Smoker 5 with tobacco waiting to smoke
Smoker 3 with match done smoking
Agent 2 giving out tobacco
Smoker 1 with paper received other items. Now smoking for the 1 time...
Agent 0 giving out tobacco
Smoker 2 with match received other items. Now smoking for the 1 time...
Smoker 1 with paper done smoking
Smoker 1 with paper waiting to smoke
Smoker 2 with match done smoking
Agent 2 giving out tobacco
Smoker 0 with paper received other items. Now smoking for the 1 time...
Smoker 2 with match waiting to smoke
Smoker 3 with match waiting to smoke
Agent 0 giving out tobacco
Smoker 2 with match received other items. Now smoking for the 2 time...
Smoker 0 with paper done smoking
Smoker 0 with paper waiting to smoke
Smoker 2 with match done smoking
Smoker 2 with match waiting to smoke
Agent 2 giving out tobacco
Smoker 1 with paper received other items. Now smoking for the 2 time...
Agent 1 giving out match
Smoker 4 with tobacco received other items. Now smoking for the 2 time...
Smoker 1 with paper done smoking
Smoker 1 with paper waiting to smoke
Smoker 4 with tobacco done smoking
Agent 0 giving out tobacco
Smoker 3 with match received other items. Now smoking for the 2 time...
Smoker 4 with tobacco waiting to smoke
Smoker 3 with match done smoking
Agent 0 giving out tobacco
Smoker 2 with match received other items. Now smoking for the 3 time...
Smoker 3 with match waiting to smoke
Smoker 2 with match done smoking
Smoker 2 has smoked 3 times and is leaving
Agent 2 giving out tobacco
Smoker 0 with paper received other items. Now smoking for the 2 time...
Smoker 0 with paper done smoking
Smoker 0 with paper waiting to smoke
Agent 1 giving out match
Smoker 5 with tobacco received other items. Now smoking for the 3 time...
Smoker 5 with tobacco done smoking
Smoker 5 has smoked 3 times and is leaving
Agent 0 giving out tobacco
Smoker 3 with match received other items. Now smoking for the 3 time...
Smoker 3 with match done smoking
Agent 1 giving out match
Smoker 4 with tobacco received other items. Now smoking for the 3 time...
Smoker 4 with tobacco done smoking
Agent 2 giving out tobacco
Smoker 1 with paper received other items. Now smoking for the 3 time...
Smoker 3 has smoked 3 times and is leaving
Smoker 4 has smoked 3 times and is leaving
Smoker 1 with paper done smoking
Agent 2 giving out tobacco
Smoker 0 with paper received other items. Now smoking for the 3 time...
Smoker 0 with paper done smoking
Smoker 0 has smoked 3 times and is leaving
Smoker 1 has smoked 3 times and is leaving
All threads stopped, exit success
server@server:/var/www/Spring-2013/OS/semaphores$
server@server:/var/www/Spring-2013/OS/semaphores$ git commit -m "added sleep to emulate both the making and smoking of the cig" smokers.c
[master 0a59def] added sleep to emulate both the making and smoking of the cig
1 file changed, 12 insertions(+), 3 deletions(-)
server@server:/var/www/Spring-2013/OS/semaphores$ make clean; make
rm -f *.o *.exe smokers
gcc smokers.c -lrt -std=gnu99 -pthread -o smokers
smokers.c: In function ‘paperSmoker’:
smokers.c:47:9: warning: implicit declaration of function ‘usleep’ [-Wimplicit-function-declaration]
./smokers
Smoker 5 with tobacco waiting to smoke
Smoker 4 with tobacco waiting to smoke
Smoker 3 with match waiting to smoke
Smoker 2 with match waiting to smoke
Smoker 1 with paper waiting to smoke
Smoker 0 with paper waiting to smoke
Agent 2 giving out tobacco
Smoker 1 with paper received other items. Now smoking for the 1 time...
Smoker 1 with paper done smoking
Agent 0 giving out tobacco
Smoker 3 with match received other items. Now smoking for the 1 time...
Smoker 1 with paper waiting to smoke
Smoker 3 with match done smoking
Agent 0 giving out tobacco
Smoker 2 with match received other items. Now smoking for the 1 time...
Smoker 2 with match done smoking
Agent 1 giving out match
Smoker 5 with tobacco received other items. Now smoking for the 1 time...
Smoker 3 with match waiting to smoke
Smoker 5 with tobacco done smoking
Agent 2 giving out tobacco
Smoker 0 with paper received other items. Now smoking for the 1 time...
Smoker 2 with match waiting to smoke
Smoker 0 with paper done smoking
Smoker 5 with tobacco waiting to smoke
Smoker 0 with paper waiting to smoke
Agent 0 giving out tobacco
Smoker 3 with match received other items. Now smoking for the 2 time...
Smoker 3 with match done smoking
Agent 1 giving out match
Smoker 4 with tobacco received other items. Now smoking for the 1 time...
Smoker 3 with match waiting to smoke
Smoker 4 with tobacco done smoking
Agent 2 giving out tobacco
Smoker 1 with paper received other items. Now smoking for the 2 time...
Smoker 4 with tobacco waiting to smoke
Smoker 1 with paper done smoking
Agent 0 giving out tobacco
Smoker 2 with match received other items. Now smoking for the 2 time...
Agent 2 giving out tobacco
Smoker 2 with match done smoking
Smoker 0 with paper received other items. Now smoking for the 2 time...
Smoker 1 with paper waiting to smoke
Smoker 2 with match waiting to smoke
Agent 1 giving out match
Smoker 5 with tobacco received other items. Now smoking for the 2 time...
Smoker 0 with paper done smoking
Smoker 0 with paper waiting to smoke
Smoker 5 with tobacco done smoking
Smoker 5 with tobacco waiting to smoke
Agent 0 giving out tobacco
Smoker 3 with match received other items. Now smoking for the 3 time...
Smoker 3 with match done smoking
Agent 1 giving out match
Smoker 4 with tobacco received other items. Now smoking for the 2 time...
Smoker 3 has smoked 3 times and is leaving
Smoker 4 with tobacco done smoking
Agent 2 giving out tobacco
Smoker 1 with paper received other items. Now smoking for the 3 time...
Smoker 1 with paper done smoking
Smoker 1 has smoked 3 times and is leaving
Agent 0 giving out tobacco
Smoker 2 with match received other items. Now smoking for the 3 time...
Smoker 2 with match done smoking
Smoker 4 with tobacco waiting to smoke
Smoker 2 has smoked 3 times and is leaving
Agent 2 giving out tobacco
Smoker 0 with paper received other items. Now smoking for the 3 time...
Smoker 0 with paper done smoking
Agent 1 giving out match
Smoker 5 with tobacco received other items. Now smoking for the 3 time...
Smoker 5 with tobacco done smoking
Smoker 0 has smoked 3 times and is leaving
Smoker 5 has smoked 3 times and is leaving
Agent 1 giving out match
Smoker 4 with tobacco received other items. Now smoking for the 3 time...
Smoker 4 with tobacco done smoking
Smoker 4 has smoked 3 times and is leaving
All threads stopped, exit success
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment