Вы находитесь на странице: 1из 4

University of duhok

College of engineering
Electrical and computer
Department

Operating system

HW
Threads and Concurrency

BY: sahmi abdullqahar

Group (b)
4.2: Using Amdahl’s Lawcalculate the speedup gain of an
application that has a 60 percent parallel component for (a) two
processing cores and (b) four processing cores.

Ans

Amdahl’s Law is speedup <= 1 / (S + (1 –S) / N) where S is the portion of the application
that must be performed serially, and N is the number of processing cores.

(a) For 2 processing cores and 60 percent parallel component S is 40 percent or 0.4
and N is 2. So, speedup is <= 1/ (0.4 + (1 –0.4)/2) -> speedup <= 1.428571 ->
Speedup gain is 1.428 times.

(b) For 4 processing cores and 60 percent parallel component S is 40 percent or 0.4
and N is 4. So, speedup is <= 1/ (0.4 + (1 –0.4)/4) -> speedup <= 1.81-> Speedup
gain is 1.81 times.

4.3: Does the multithreaded web server described in Section 4.1


exhibit task or data parallelism .
ANS
In a web server environment, a number of users request for the application. Thus, when any
application is executed through the web server, a number of different threads are executed
for different users. In graphic user interface, different threads are executed for different
tasks. For example, first thread is used to fix the bugs, the second thread is responsible for
the execution of the program and another one is responsible for the performance of the
program. If any program is executed using only one thread, then, if that thread is blocked,
the total application will stop responding. So, it can be said that the performance of multi-
threading is much better than system with single thread.

4.6: What resources are used when a thread is created? How


do they differ from those usedwhen a process is created?
ANS
A context must be created, including a register set storage location for storage during
context switching, and a local stack to record the procedure call arguments,
returnvalues, and return addresses, and thread-local storage. A process creation results in
mem-orybeing allocated for program instructions and data, as well as thread-like storage.
Code mayalso be loaded into the allocated memory.
4.6: What resources are used when a thread is created? How
do they differ from those usedwhen a process is created?
ANS
A context must be created, including a register set storage location for storage during
context switching, and a local stack to record the procedure call arguments,
returnvalues, and return addresses, and thread-local storage. A process creation results in
mem-orybeing allocated for program instructions and data, as well as thread-like storage.
Code mayalso be loaded into the allocated memory.

4.10: Which of the following components of program state are


shared across threads in a multithreaded process?
a. Register values
b. Heap memory
c. Global variables
d. Stack memory
ANS
The threads of a multithreaded process share heap memory and global variables. Each thread
has its separate set of register values and a separate stack.

4.13: Is it possible to have concurrency but not parallelism?


Explain.
ANS
Both are a form of an operating system. Sometimes, to complete a task, both methods
needed to finish the task and sometimes one. The priority to select, which form is better,
depends upon the requirement of system and according to that operating system coding
created.

Yes, it is possible to have concurrency but not parallelism.

Concurrency:

Concurrency means where two different tasks or threads start working together in an
overlapped time period, however, it does not mean they run at same instant

Вам также может понравиться