(Homework Solution): Question: List references where needed 1. Describe the difference between a process and a thread 2. Which o…

List references where needed 1. Describe the difference between a process and a thread 2. Which of the following components of program are shared across threads in a multithreaded process ? a. Register values b. Heap memory c. Global variables d. Stack memory 3. What is a spinlock? What is an alternative to using spinlocks? 4. What is the distinction between the critical section and the critical data? 5. Describe the difference between a monitor and a semaphore

List references where needed 1. Describe the difference between a process and a thread 2. Which of the following components of program are shared across threads in a multithreaded process ? a. Register values b. Heap memory c. Global variables d. Stack memory 3. What is a spinlock? What is an alternative to using spinlocks? 4. What is the distinction between the critical section and the critical data? 5. Describe the difference between a monitor and a semaphore

Expert Answer

Answer 1)

The Process and Thread are the essentially associated. The process is an execution of a
program whereas thread is an execution of a program driven by the environment of a process.

Another major point which differentiates process and thread is that processes are isolated with
each other whereas threads share memory or resources with each other.

The main key difference between process and thread are below:

All threads of a program are logically contained within a process.

A process is heavy weighted, but a thread is light weighted.

A program is an isolated execution unit whereas thread is not isolated and shares memory.

A thread cannot have an individual existence; it is attached to a process. On the other hand,
a process can exist individually.

At the time of expiration of a thread, its associated stack could be recovered as every thread
has its own stack. In contrast, if a process dies, all threads die including the process.

Answer 2)
Its Heap Memory.

Global variables are also shared but they are dependent on the platform.

Registers and stacks are specific to their own threads so can’t be shared.

Answer 3)
In a loop a thread waits simply (‘spins’) checks repeatedly until the lock becomes available.

This type of lock is a spin lock. The lock is a kind of busy waiting, as the threads remains active by not performing a useful task.

The spin locks are to release explicitly, although some locks are released automatically when the tread blocks.

The primary disadvantage of a spinlock is that, while waiting to acquire a lock, it wastes time that might be productively
spent elsewhere. There are two ways to avoid this:

Do not acquire the lock. In many situations it is possible to design data structures that do not require locking,
e.g. by using per-thread or per-CPU data and disabling interrupts.

Switch to a different thread while waiting. This typically involves attaching the current thread to a queue of
threads waiting for the lock, followed by switching to another thread that is ready to do some useful work.
This scheme also has the advantage that it guarantees that resource starvation does not occur as long as all
threads eventually relinquish locks they acquire and scheduling decisions can be made about which thread should progress first.
Spinlocks that never entail switching, usable by real-time operating systems, are sometimes called raw spinlocks.

Answer 4)
A critical section in which the process may be changing common variables, updating table, writing a file and perform
another function. The important problem is that if one process is executing in its critical section, no other process
is to be allowed to execute in its critical section. Each process much request permission to enter its critical section.

A semaphore is a tool for synchronization and it is used to remove the critical section problem which is that no two
processes can run simultaneously together so to remove this two signal operations are used named as wait and signal
which is used to remove the mutual exclusion of the critical section. as an unsigned one of the most important
synchronization primitives, because you can build many other Decrementing the semaphore is called acquiring or locking it,
incrementing is called releasing or unlocking.

A mutex is a special case of the semaphore and also known as binary mutex it can have only two values minimum of 0 and
maximum of 1, meaning it can be either locked or unlocked. It is used to prevent more than one thread from accessing the
same data while allowing multiple threads to run on it.

Answer 5)
A Monitor is an object designed to be accessed from multiple threads. The member functions or methods of a monitor object
will enforce mutual exclusion, so only one thread may be performing any action on the object at a given time. If one thread
is currently executing a member function of the object then any other thread that tries to call a member function of that
object will have to wait until the first has finished.

A Semaphore is a lower-level object. You might well use a semaphore to implement a monitor. A semaphore essentially is just
a counter. When the counter is positive, if a thread tries to acquire the semaphore then it is allowed, and the counter is
decremented. When a thread is done then it releases the semaphore, and increments the counter.

If the counter is already zero when a thread tries to acquire the semaphore then it has to wait until another thread releases
the semaphore. If multiple threads are waiting when a thread releases a semaphore then one of them gets it. The thread that
releases a semaphore need not be the same thread that acquired it.

A monitor is like a public toilet. Only one person can enter at a time. They lock the door to prevent anyone else coming in, do their stuff, and then unlock it when they leave.

A semaphore is like a bike hire place. They have a certain number of bikes. If you try and hire a bike and they have one free then you can take it, otherwise you must wait. When someone returns their bike then someone else can take it. If you have a bike then you can give it to someone else to return — the bike hire place doesn’t care who returns it, as long as they get their bike back.

Thank you.

iWriteHomework
Order NOW for a 10% Discount
Pages (550 words)
Approximate price: -

Why Us?

Top Quality and Well-Researched Papers

All ourbpapers are written from scratch. In fact, Clients who ask for paraphrasing services are highly discouraged. We have writers ready to craft any paper from scratch and deliver quality ahead of time.

Professional and Experienced Academic Writers

Our writers keeps you posted on your papers progress - providing you with paper outline/draft. You are also at liberty to communicate directly with your writer.

Free Unlimited Revisions

If you think we missed something, send your order for a free revision. You have 10 days to submit the order for review after you have received the final document. You can do this yourself after logging into your personal account or by contacting our support.

Prompt Delivery and 100% Money-Back-Guarantee

All papers are always delivered on time, in many cases quite ahead of time. In case we need more time to master your paper, we may contact you regarding the deadline extension. In case you cannot provide us with more time, a 100% refund is guaranteed.

Original & Confidential

We use several writing tools checks to ensure that all documents you receive are free from plagiarism. Our editors carefully review all quotations in the text. We also promise maximum confidentiality in all of our services.

24/7 Customer Support

Our support agents are available 24 hours a day 7 days a week and committed to providing you with the best customer experience. Get in touch whenever you need any assistance.

Try it now!

Calculate the price of your order

Total price:
$0.00

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

Our Services

No need to work on your paper at night. Sleep tight, we will cover your back. We offer all kinds of writing services.

Essays

Essay Writing Service

No matter what kind of academic paper you need and how urgent you need it, you are welcome to choose your academic level and the type of your paper at an affordable price. We take care of all your paper needs and give a 24/7 customer care support system.

Admissions

Admission Essays & Business Writing Help

An admission essay is an essay or other written statement by a candidate, often a potential student enrolling in a college, university, or graduate school. You can be rest assurred that through our service we will write the best admission essay for you.

Reviews

Editing Support

Our academic writers and editors make the necessary changes to your paper so that it is polished. We also format your document by correctly quoting the sources and creating reference lists in the formats APA, Harvard, MLA, Chicago / Turabian.

Reviews

Revision Support

If you think your paper could be improved, you can request a review. In this case, your paper will be checked by the writer or assigned to an editor. You can use this option as many times as you see fit. This is free because we want you to be completely satisfied with the service offered.

× Contact Live Agents