Question: Suppose that a program has two threads, each executing the get _ account function, shown below. Identify a race condition in this code. int accounts
Suppose that a program has two threads, each executing the getaccount function, shown below. Identify a race condition in this code.
int accountsLIMIT; int account count ;
void getaccountvoid "tid
char lineptr NULL;
sizet len ;
while accountcount LIMIT
Read user input from terminal and store it in lineptr
getline&lineptr, &len, stdin:
Convert user input to integer
Assume user entered valid integer value
int enteredaccount atoilineptr;
accountsaccountcount enteredaccount;
account count;
Deallocate memory that was allocated by getline call
freelineptr:
return NULL;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
