In computer science, yield is an action that occurs in a computer program during multithreading, of forcing a processor to relinquish control of the current running thread, and sending it to the end of the running queue, of the same scheduling priority.

Examples

edit

Different programming languages implement yielding in various ways.

  • pthread_yield() in the language C, a low level implementation, provided by POSIX Threads[1]
  • std::this_thread::yield() in the language C++, introduced in C++11.
  • The Yield method is provided in various object-oriented programming languages with multithreading support, such as C# and Java.[2] OOP languages generally provide class abstractions for thread objects.
  • yield in Kotlin
  • sched_yield() in the C standard library, which causes the calling thread to relinquish the CPU.[3]

In coroutines

edit

Coroutines are a fine-grained concurrency primitive, which may be required to yield explicitly. They may enable specifying another function to take control. Coroutines that explicitly yield allow cooperative multitasking.

See also

edit

References

edit
  1. ^ "pthread_yield". IBM.
  2. ^ "Thread.yield". Javamex. Retrieved 24 June 2011.
  3. ^ "sched_yield(2) - Linux manual page". man7.org. Retrieved 2025-06-02.

📚 Artikel Terkait di Wikipedia

Yield

Look up yield in Wiktionary, the free dictionary. Yield may refer to: Yield (multithreading) is an action that occurs in a computer program during multithreading

Thread (computing)

functional programming community. Multithreading is mainly found in multitasking operating systems. Multithreading is a widespread programming and execution

Coroutine

example is often used as an introduction to multithreading, two threads are not needed for this: the yield statement can be implemented by a jump directly

Preemption (computing)

MS-DOS compatible systems natively supporting preemptive multitasking/multithreading include Concurrent DOS, Multiuser DOS, Novell DOS (later called Caldera

Arrow Lake (microprocessor)

multiplications per cycle (assuming they are independent of course). Simultaneous multithreading (SMT) has been removed from Arrow Lake's Lion Cove P-cores. SMT first

Cooperative multitasking

order to run multiple applications concurrently, processes voluntarily yield control periodically or when idle or logically blocked. This type of multitasking

Microarchitecture

Another technique that has become more popular recently is multithreading. In multithreading, when the processor has to fetch data from slow system memory

Power10

Power10 is a superscalar, multithreading, multi-core microprocessor family, based on the open source Power ISA, announced in August 2020 and available