PDA

View Full Version : Semaphore script



Rovio
December 3rd, 2015, 09:28 PM
Hello, i have problem with a semaphore script. There must be 3 printers and we have 7 books to print which have 7 chapters each.
Printing times each chapter:
Ch1 => 5 seconds
Ch2 => 6s
Ch3 => 7s
Ch4 => 4s
Ch5 => 5s
Ch6 => 6s
Ch7 => 3s

Any ideas how to write script and solve this problem as fastes we can ? It must be C language

QIII
December 3rd, 2015, 09:32 PM
Have you consulted with your instructor?

Rovio
December 3rd, 2015, 10:44 PM
Its must be something like this:



TIME

PRINTERS



START
1
2
3


5s
Ch1 (5s)
Ch2(6s)
Ch3(7s)














If printer is free then it stars printing next chapter

mystics
December 3rd, 2015, 10:52 PM
I'm not during your homework for you! You can easily learn about basic semaphore functions with the following man pages:



man 3 sem_init
man 3 sem_wait
man 3 sem_post


Beyond that, there are a lot of tutorials online about some basic semaphore usage, how to solve concurrency problems, and how to avoid situations like deadlock. You don't need us to do your homework for you. There's more than enough information out there to help you figure out how to do it yourself.

QIII
December 3rd, 2015, 10:54 PM
While we are glad to help with minor sticking points, Ubuntu Forums is not a homework service.

Closed.