a) Assume that you are trying to download a large 2-GB file from the Internet. The file is available from a set of mirror servers, each of which can deliver a subset of the file's bytes; assume that a given request specifies the starting and ending bytes of the file. Explain how you might use threads to improve the download time. b) Does Peterson's solution to the mutual-exclusion problem shown in Fig. 2-24 (see attached pic) of MOS4e work when process scheduling is preemptive? How about when it is nonpreemptive? c) The producer-consumer problem can be extended to a system with multiple producers and consumers that write (or read) to (from) one shared buffer. Assume that each producer and consumer runs in its own thread. Will the solution presented in Fig. 2-28 (see attached pic) of MOS4e, using semaphores, work for this system?

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

Hello. Please answer the attached Operating Systems question and its parts correctly. You don't have to give a very long answer to each part, just give a sufficient answer. 

*If you answer the question parts correctly, I will give you a thumbs up. Thanks.

#define FALSE 0
#define TRUE 1
#define N
2
int turn;
int interested[N];
void enter_region(int process);
{
int other;
/* the opposite of process */
other 1 process;
interested[process] = TRUE;
turn = process;
/* show that you are interested */
/* set flag */
while (turn == process && interested [other] == TRUE) /* null statement */ ;
}
void leave_region(int process)
{
}
*
/* number of processes */
/* whose turn is it? */
/* all values initially 0 (FALSE) */
/* process is 0 or 1 */
/* number of the other process */
interested[process] = FALSE;
/* process: who is leaving */
/* indicate departure from critical region */
Figure 2-24. Peterson's solution for achieving mutual exclusion.
Figure 2-24 for Part B
#define N 100
typedef int semaphore;
semaphore mutex = 1;
semaphore empty = N;
semaphore full = 0;
void producer(void)
{
int item;
}
while (TRUE) {
}
item= produce_item();
down(&empty);
down(&mutex);
insert_item(item);
up(&mutex);
up(&full);
void consumer(void)
{
int item;
while (TRUE) {
down(&full);
down(&mutex);
item= remove_item();
up(&mutex);
up(&empty);
consume_item(item);
/* number of slots in the buffer */
/* semaphores are a special kind of int */
/* controls access to critical region */
/* counts empty buffer slots */
/* counts full buffer slots */
/* TRUE is the constant 1 */
/* generate something to put in buffer */
/* decrement empty count */
/* enter critical region */
/* put new item in buffer */
/* leave critical region */
/* increment count of full slots */
/* infinite loop */
/* decrement full count */
/* enter critical region */
/* take item from buffer */
/* leave critical region */
/* increment count of empty slots */
/* do something with the item */
Figure 2-28. The producer-consumer problem using semaphores.
Figure 2-28 for Part C
Transcribed Image Text:#define FALSE 0 #define TRUE 1 #define N 2 int turn; int interested[N]; void enter_region(int process); { int other; /* the opposite of process */ other 1 process; interested[process] = TRUE; turn = process; /* show that you are interested */ /* set flag */ while (turn == process && interested [other] == TRUE) /* null statement */ ; } void leave_region(int process) { } * /* number of processes */ /* whose turn is it? */ /* all values initially 0 (FALSE) */ /* process is 0 or 1 */ /* number of the other process */ interested[process] = FALSE; /* process: who is leaving */ /* indicate departure from critical region */ Figure 2-24. Peterson's solution for achieving mutual exclusion. Figure 2-24 for Part B #define N 100 typedef int semaphore; semaphore mutex = 1; semaphore empty = N; semaphore full = 0; void producer(void) { int item; } while (TRUE) { } item= produce_item(); down(&empty); down(&mutex); insert_item(item); up(&mutex); up(&full); void consumer(void) { int item; while (TRUE) { down(&full); down(&mutex); item= remove_item(); up(&mutex); up(&empty); consume_item(item); /* number of slots in the buffer */ /* semaphores are a special kind of int */ /* controls access to critical region */ /* counts empty buffer slots */ /* counts full buffer slots */ /* TRUE is the constant 1 */ /* generate something to put in buffer */ /* decrement empty count */ /* enter critical region */ /* put new item in buffer */ /* leave critical region */ /* increment count of full slots */ /* infinite loop */ /* decrement full count */ /* enter critical region */ /* take item from buffer */ /* leave critical region */ /* increment count of empty slots */ /* do something with the item */ Figure 2-28. The producer-consumer problem using semaphores. Figure 2-28 for Part C
Please answer the following Operating Systems question and its three parts:
a) Assume that you are trying to download a large 2-GB file from the Internet. The file is available from a
set of mirror servers, each of which can deliver a subset of the file's bytes; assume that a given request
specifies the starting and ending bytes of the file. Explain how you might use threads to improve the
download time.
b) Does Peterson's solution to the mutual-exclusion problem shown in Fig. 2-24 (see attached pic) of
MOS4e work when process scheduling is preemptive? How about when it is nonpreemptive?
c) The producer-consumer problem can be extended to a system with multiple producers and consumers
that write (or read) to (from) one shared buffer. Assume that each producer and consumer runs in its own
thread. Will the solution presented in Fig. 2-28 (see attached pic) of MOS4e, using semaphores, work for
this system?
* Please answer correctly and I will give you Thumbs Up. You do not need to give very long
explaination for each part. Thank you.
Transcribed Image Text:Please answer the following Operating Systems question and its three parts: a) Assume that you are trying to download a large 2-GB file from the Internet. The file is available from a set of mirror servers, each of which can deliver a subset of the file's bytes; assume that a given request specifies the starting and ending bytes of the file. Explain how you might use threads to improve the download time. b) Does Peterson's solution to the mutual-exclusion problem shown in Fig. 2-24 (see attached pic) of MOS4e work when process scheduling is preemptive? How about when it is nonpreemptive? c) The producer-consumer problem can be extended to a system with multiple producers and consumers that write (or read) to (from) one shared buffer. Assume that each producer and consumer runs in its own thread. Will the solution presented in Fig. 2-28 (see attached pic) of MOS4e, using semaphores, work for this system? * Please answer correctly and I will give you Thumbs Up. You do not need to give very long explaination for each part. Thank you.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Concept of Threads
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education