Using_ begin thread spawn sub processes that sell pretend tickets to a show. the
ID: 3864311 • Letter: U
Question
Using_ begin thread spawn sub processes that sell pretend tickets to a show. the tickets correspond to slots in an array call it tickets. If ticket[i] == 1 it means that the ticket is available. If you sell that ticket change the value of ticket[i] to 0. To do this create a function called sell tickets that takes as input an array of tickets and returns a 0 if it sold a ticket or a 1 if there are no tickets left. Just before the return print that the handle sold a ticket. Since the array is a location in memory to be shared by the spawned processes you need to use the wait and signal functions to control access to the array. Read about them and then deploy them in your program.Explanation / Answer
uintptr_t _beginthread( // NATIVE CODE void( __cdecl *start_address )( void * ), unsigned stack_size, void *arglist ); uintptr_t _beginthread( // MANAGED CODE void( __clrcall *start_address )( void * ), unsigned stack_size, void *arglist ); uintptr_t _beginthreadex( // NATIVE CODE void *security, unsigned stack_size, unsigned ( __stdcall *start_address )( void * ), void *arglist, unsigned initflag, unsigned *thrdaddr ); uintptr_t _beginthreadex( // MANAGED CODE void *security, unsigned stack_size, unsigned ( __clrcall *start_address )( void * ), void *arglist, unsigned initflag, unsigned *thrdaddr );
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.