Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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 -(chan*)malloc(sizeof(char)*255);
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;
}
}
Choices:
11-15
7-15
10-15
7-8
Or The function is thread safe and does not need a critical section

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

10th Edition

0137916787, 978-0137916788

More Books

Students also viewed these Databases questions

Question

What are the disadvantages of arbitration?

Answered: 1 week ago

Question

Write Hund's rule?

Answered: 1 week ago

Question

=+How should it be delivered?

Answered: 1 week ago