0

EDIT: This is a clarification of a definition based on what I read. It's different from other questions because I as about "basic unit of CPU utilization"

I am currently taking an Operating Systems class at my university and we recently started learning about threads.

A thread (based on what I read in the textbook "Operating Systems Concepts") is described as a "basic unit of CPU utilization". What does it mean if it is a "basic unit of CPU utilization"

Does this mean that the CPU executes a thread or threads belonging to a process as opposed to "executing a process itself"?

nnelson
  • 3
  • 3
  • Possible duplicate of [Process vs. Thread](http://stackoverflow.com/questions/1762418/process-vs-thread) – Sam R. Feb 06 '16 at 03:57

3 Answers3

0

A process is basically a set of threads that share an address space with each other.

Each thread represents a separate thread of execution by the CPU(s), so it has has its own execution context. With preemptive threads, this normally means a complete set of registers (including program counter), so each thread can be suspended and resumed whenever needed. Depending on how many processors are available, an arbitrary number of those threads may be executing at any given time.

Jerry Coffin
  • 476,176
  • 80
  • 629
  • 1,111
0

A thread is a stream of instructions for execution.The reason for having threads (Ada "tasks") is to be able to do multiple things at the same time (or I should say ONE WAY of doing multiple things at the same time.

You could do multiple things at the same time by having multiple programs running at the same time (the traditional unix method). The reason for having threads is that they allow faster data exchange. Threads in the same process can share the same address space allowing data exchanges through memory (albeit, this requires implementing synchronization). Some languages, such as Ada, incorporate safe mechanisms for threads to exchange data. Most languages, however, for the programmer to implement safe methods for threads to change data.

The answer to your question depends upon the implementation. There are two ways of implementing thread.

1: Threads are implemented in a library linked to the application. The library uses timers to interrupt the application and switch among thread.

In this model, the operating system knows absolutely nothing about the threads. The thread is entirely a creation of the process itself.

In this method, only one thread at a time within a process executes (interleaved execution).

2: The operating system implements threads. Threads are scheduled for execution by the operating system.

In this model a process consists of an address space that is shared by one or more threads. In a multiprocessor system, threads of a process can execute in parallel.

The difference between the two models above is that in #1, a PROCESS is the basic unit of scheduling. The Operating schedules processes for execution and the process shifts between threads. The process schedules THREADS for execution.

In #2, a THREAD is the basic unit of scheduling by the operating system. When a thread is executed, the operating system must load the process address space as well.

-=-=-=-=-=-=-=-=-=-=-=-=-=

Take what you read in "Operating Systems Concepts" with a grain of salt. "basic unit of CPU utilization" is total BS concept. That book invents concepts that have no relation to reality.

Community
  • 1
  • 1
user3344003
  • 20,574
  • 3
  • 26
  • 62
  • You said "In #2, a THREAD is the basic unit of scheduling by the operating system. The process schedules THREADS for execution." Dont you mean the OS schedules threads for execution. Because earlier in your response you say "The operating system implements threads. Threads are scheduled for execution by the operating system." – nnelson Feb 06 '16 at 05:54
  • Cut and past issue. Edited. – user3344003 Feb 06 '16 at 15:48
0

Threads are subsets of a process.

A process is an ACTIVE PROGRAM.

A program generally consists of various instructions.

Groups of these instructions form the threads and are generally processes as one chunk (unit) by CPU.

The threads of a single process share the same memory, Though the stacks of the two are different.

The CPU can perform one thread of a process, switch to another thread of another process and then perform the remaining threads. Basically in lay man's words, Threads are like parts of a process that are processed at one go(Basic Unit Of CPU Utilization).

The concept of having threads is for having maximum CPU utilization.

So the answer to your last question is Yes.

Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
G2G
  • 1
  • 1