Consider the following fragment of code. If you were to use…
Consider the following fragment of code. If you were to use this function in a threaded scenario, what portion of it would be the critical section? Try to minimize the size of the critical section given the options provided. struct Book{ char* title; char* user_name; int is_checked_out; } void check_out(char* userName, int bookID, Book* books){ char* user_name = (char*)malloc(sizeof(char) * MAX_USERNAME_LEN); strcpy(user_name, userName); Book* book = &books[bookID]; if(!book->is_checked_out) { book->is_checked_out = 1; book->user_name = user_name; books[bookID] = book; } }
Read Details