Computers and Technology, 21.11.2019 21:31 sethjohnson386pbnm3x
This programming question is about semaphore. create two threads t1 and t2. t1 and t2 share an integer data counter. the job of t1 is to increase the value of counter by 1 when t1 is scheduled. the job of t2 is to decrease the value of counter by 1 when t2 is scheduled. because counter is a critical section, you need to use semaphore to implement mutual exclusion between t1 and t2.here is the api you may use: sem_init: initialize an unnamed semaphoresem_wait: lock a semaphore, which is equivalent to the p operation. sem_post: unlock a semaphore, which is equivalent to the v operation. sem_destroy: destroy an unnamed semaphore. here is the basic structure of the program: int counter; //shared between t1 and t2main(){create semaphore; create t1; create t2; destroy semaphore; }thread t1 routine(){while (1){p(); increase counter by 1; output the value of counter; v(); }}thread t2 routine(){while (1){p(); decrease counter by 1; output the value of counter; v(); }}
Answers: 1
Computers and Technology, 23.06.2019 09:30
Why is an outfitting a workspace with video games in a technology development company considered a strategic use of money
Answers: 1
Computers and Technology, 23.06.2019 16:00
What is the biggest difference between section breaks and regular page breaks? section breaks are more difficult to add than page breaks. section breaks make it easier for you to view the document as an outline. section breaks allow you to have areas of the document with different formatting. section breaks are smaller than regular page breaks.
Answers: 2
Computers and Technology, 24.06.2019 15:30
Emma is using an artificial intelligence system, which contains information on botany, to identify a type of plant from an image. what type of ai is emma using?
Answers: 1
This programming question is about semaphore. create two threads t1 and t2. t1 and t2 share an integ...
Mathematics, 21.05.2021 06:00
History, 21.05.2021 06:00
Mathematics, 21.05.2021 06:00
Mathematics, 21.05.2021 06:00
Mathematics, 21.05.2021 06:00
English, 21.05.2021 06:00
Physics, 21.05.2021 06:00
Physics, 21.05.2021 06:00
Biology, 21.05.2021 06:00
Advanced Placement (AP), 21.05.2021 06:00
Advanced Placement (AP), 21.05.2021 06:00