answersLogoWhite

0


Best Answer

A thread is similar to a separate process, in that it can do stuff (process) independently of other threads. But it is lightweight, since the operating system doesn't have to give it its own memory space, since it shares memory with the other threads in the process.

[Note: a thread or LWP shares the same instruction memory space as other threads of that process, but has its own datamemory space]

User Avatar

Wiki User

12y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

11y ago

Lightweight and heavyweight processes refer the mechanics of a multi-processing system.

In a lightweight process, threads are used to divvy up the workload. Here you would see one process executing in the OS (for this application or service.) This process would posess 1 or more threads. Each of the threads in this process shares the same address space. Because threads share their address space, communication between the threads is simple and efficient. Each thread could be compared to a process in a heavyweight scenario.

In a heavyweight process, new processes are created to perform the work in parallel. Here (for the same application or service), you would see multiple processes running. Each heavyweight process contains its own address space. Communication between these processes would involve additional communications mechanisms such as sockets or pipes.

The benefits of a lightweight process come from the conservation of resources. Since threads use the same code section, data section and OS resources, less overall resources are used. The drawback is now you have to ensure your system is thread-safe. You have to make sure the threads don't step on each other. Fortunately, Java provides the necessary tools to allow you to do this.

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

A:

It's been a while since I've heard anyone refer to a thread as a lightweight task. The name however requires you understand what a task and what a thread is.

A task is a process executed by the operating system in it's own "process". That means for example, if you're running from a Linux/Unix command prompt a program, it starts up and then you can put it in the background and let it run there where it's on its own. That task is basically a "thread of the operating system" as it's a separate executing process that runs "as a child" of the operating system.

There are several ways of running these from within a program you've written. One method is to "fork()" which splits your running program into two separate running programs where one continues executing down one path and the other follows another. Now, if you kill one of the processes from the command prompt or from a task manager, the other will continue to run. When you fork, you still have a limited amount of shared resources between the two processes as they shared a common entry point (meaning main() function). Functions such as spawnl() actually tell the operating system to spawn a new process instead by starting another executable file.

The alternative is a thread which is second procedure running within a program running simultaneously (if you have more than one processor core) or concurrently (if it's running on the same core) but following again a separate path of execution. If you kill the process for the application, both threads will die. Resources are completely shared between threads and you have to be careful not to accidentally overwrite the variables used by one thread from another.

In systems which don't guarantee "cache coherency", it is even important to make sure that shared integers or boolean values are either mutexed or atomic. This will make sure that before a thread tries to access a value, they are synchronized between threads. On more modern architectures where cache values can be "locked", even reading a value which was changed by another core before it has been synchronized and unlocked can generate an exception causing your program to crash.

A:

A thread is called a lightweight task because it does not require a full context switch sequence in order to be dispatched when the previous thread was part of the same task.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Why thread is called lightweight task?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering
Related questions

Why LDAP is called lightweight?

the ldap is independent of other process & it self as a thread and not use OS memory so its called lightweight


What is a thread in c?

A thread is basically a lightweight process.


What single task process requests from the kernel?

A thread.


A single task such as the task of printing a file that process request from the kernel?

Thread


What is a self contained task within a process?

Thread


What is a self-contained well-defined task within a process?

Thread


To use a needle and thread?

To use a needle and thread could be called sewing.To use a needle and thread could be called quilting. To use a needle and thread could be called embroidery. To use a needle and thread could be called suturing.


Can the subroutines of a high level language be called processes?

No. A subroutine (also known as a procedure or function) is best thought of as being a task. The executable (program) is the actual process. Every process has at least one thread of execution and each thread has its own local call stack. Thus multiple threads may concurrently execute the same task independently of any other threads within the same process. This is useful when we have a large or time-consuming task which can be broken down or divided up into smaller instances of the same task; each thread handles a small portion of the overall task and operates concurrently with all other instances of that task. Depending on how many CPU cores we have available, multiple threads of execution should complete the whole task quicker than a single thread would have. That is, if we divide the task into four, we could potentially complete the whole task in 1/4 of the time it would take with just one thread of execution.


What is thread holder?

the holder of a thread is called a spool


Describe a simple scheme in which there are as many lightweight processes as there are runnable threads?

Start with only a single LWP and let it select a runnable thread. When arunnable thread has been found, the LWP creates another LWP to look for anext thread to execute. If no runnable thread is found, the LWP destroys itself.


What is a lightweight bayou vessel called?

pirogue


How do you measure major diameter of internal thread?

The major diameter is the diameter of the crest of the thread. Use a Vernier gage and mesure the diameter of the crest points of contact ( maximum external thread diameter). Unified National thread series defines the expected major diamter and tolerance. For internal threads ( nuts) the major diameter is the diameter of the roots of the thread.