Skip to content

CodeIsLife-h/205-concurrency

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hotdog Manager

A multi-threaded producer-consumer program that simulates hotdog making and packing using pthreads.

Compilation

gcc -std=c11 -o hotdog_manager hotdog_manager.c -lpthread

Usage

./hotdog_manager <N> <S> <M> <P>
  • N: Total hot dogs to produce
  • S: Buffer size (must be less than N)
  • M: Number of maker threads
  • P: Number of packer threads (max 30)

Example

./hotdog_manager 10 5 2 3

Running Commands Multiple Times

PowerShell (Windows)

Method 1: For loop

for ($i=1; $i -le 5; $i++) { ./hotdog_manager.exe 10 5 2 3 }

Method 2: Range operator

1..5 | ForEach-Object { ./hotdog_manager.exe 10 5 2 3 }

Method 3: With run number display

1..5 | ForEach-Object { Write-Host "=== Run $_ ==="; ./hotdog_manager.exe 10 5 2 3 }

Bash/Linux/Mac

Method 1: Brace expansion

for i in {1..5}; do ./hotdog_manager 10 5 2 3; done

Method 2: C-style for loop

for ((i=1; i<=5; i++)); do ./hotdog_manager 10 5 2 3; done

Method 3: While loop

i=1; while [ $i -le 5 ]; do ./hotdog_manager 10 5 2 3; i=$((i+1)); done

Method 4: With run number display

for i in {1..5}; do echo "=== Run $i ==="; ./hotdog_manager 10 5 2 3; done

Output

The program generates a log.txt file containing:

  • Order details (N, S, M, P)
  • Production log (maker puts, packer gets)
  • Summary statistics (per-maker and per-packer counts)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors