Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6078063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:47:28+00:00 2026-05-23T10:47:28+00:00

I read this Wikipedia text slice: Because a cooperatively multitasked system relies on each

  • 0

I read this Wikipedia text slice:

Because a cooperatively multitasked system relies on each process regularly giving up time to other processes on the system, one poorly designed program can consume all of the CPU time for itself or cause the whole system to hang.

Out of curiosity, how does one give up that time? Is this some sort of OS call? Let’s think about non-preemptive cases like fibers or evented IO that do cooperative multitasking. How do they give up that time?

Take this NodeJS example:

var fs = require('fs');
fs.readFile('/path/to/file', function(err, data) {});

It is obvious to me that the process does nothing while it’s waiting for the data, but how does V8 in this case give up time for other processes?

Let’s assume Linux/Windows as our OS.

Edit: I found out how Google is doing this with their V8.

On Windows they basically sleep zero time:

void Thread::YieldCPU() {
  Sleep(0);
}

And on Linux they make an OS call:

void Thread::YieldCPU() {
  sched_yield();
}

of sched.h.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T10:47:28+00:00Added an answer on May 23, 2026 at 10:47 am

    Yes, every program participates in the scheduling decisions of the OS, so you have to call a particular syscall that tells the kernel to take back over. Often this was called yield(). If you imagine how difficult it is to guarantee that a paticular line of code is called at regular, short intervals, or even at all, you get an idea of why cooperative multitasking is a suboptimal solution.

    In your example, it is the javascript engine itself is interrupted by the OS scheduler, if it’s a preemptive OS. If it’s a cooperative one, then no, the engine gets no work done, and neither does any other process. As a result, such systems are usually not suitable for real-time (or even serious) workloads.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ever wonder what wikipedia's database schema looks like? I recently read this thread from
I've read conflicting things on this. From Wikipedia: Controller Processes and responds to events,
What exactly is Reflection? I read the Wikipedia article on this subject and I
I read this answer on SO: Because the recursive mutex has a sense of
I have this very simple python code to read xml for the wikipedia api:
I've read about binary searches on Wikipedia for the first time today and just
According to this Wikipedia article on Google App Engine : Developers have read-only access
I'm using read line to get some text from wikipedia. But read line only
On Wikipedia I read: Borland Delphi 2006 [...] Each version is available in two
Recently I read this Wikipedia article regarding the Dining Philosophers problem but I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.