semaphore SemA (ID:4514)
Project Creator: |
yeppey2004
FC Member For 6241 Days
Credits 20 Completed Proj. Num. 0 / 0 Total payment USD 0.00 Avg Daily Online 0.00 h (From 21/5/2007) Available on MSN/Skype No Last Login 6/8/2008 Peers Rating 0.00% ![]() ![]() ![]() |
---|---|
Budget: | Less than 250 |
Created: | 6/8/2008 9:00:17 PM EST |
Bidding Ends: | 6/11/2008 9:00:17 PM EST ( Expired ) |
Development Cycle: | 1 Days |
Bid Count: | 8
|
Average Bid: | 155.00 |
Project Description:
Implement a program which uses semaphores to manage a shared file 1. You shall create a process. This process shall: * Create a file, File.txt, in the current directory (cwd). * Write it's pid (followed by a Carriage Return and Newline) in the file. * Close the file File.txt * Create a semaphore SemA for the file File.txt. * Create 5 threads. Each thread shall have a unique identifier which you establish when you create the thread. Use the POSIX version of threads (i.e. pthread_create()) * Block/wait for all ten threads to complete their work * Destroy the semaphore, then exit 2. Each thread shall perform the following: * Once every second, open the file File.txt and write your unique thread identifier of that thread (followed by a Carriage Return and Newline) * Close the file File.txt * Repeat 4 more times (so it writes to the file 5 times each), then exit You will need to use the following POSIX system calls for creating and managing the semaphores with: sem_init(), sem_wait(), sem_post(), and sem_destroy() Each thread shall use sem_wait on SemA when it opens File.txt and sem_post() on SemA when it closes File.txt. |
|
Job Type | C/C++ |
Attached Files: | N/A |