spartacus
spartacus

Reputation: 583

How operating system understands if a thread has finished?

When we start a thread Operating System puts that thread to run queue, and operating system's scheduler run that thread when the time(quantum) comes, so how operating system understands if that thread has finished it's operation?

Upvotes: 0

Views: 140

Answers (2)

user3344003
user3344003

Reputation: 21607

There are generally two mechanisms for terminating kernel threads. They are the same as for terminating processes.

  1. An explicit call to a system service to terminate the thread; or
  2. An implicit call to a system service to terminate that is invoked when the thread's main function exits.

Upvotes: 1

Gabe Sechan
Gabe Sechan

Reputation: 93542

The thread calls an OS-specific function. That function tells the OS that its done. In most languages/frameworks this will be done behind the scenes for you.

Upvotes: 1

Related Questions