Byeongin Yoon
Byeongin Yoon

Reputation: 4047

How does OS insert callback function to event-queue in nodejs after complete i/o operation?

I heard about 'poll', 'os notify to nodejs ~ bla bla', 'process communication', etc. But I can't understand how really does OS insert(queue, put) callback function which we set to event-queue after complete its i/o operation or http operation. Just OS already know the address of event-queue?

please give me some light.

Upvotes: 0

Views: 77

Answers (1)

Brendan
Brendan

Reputation: 37232

Nodejs is javascript, which means there's a large layer of hideous bloat (a javascript interpreter) between the OS and the javascript code itself. This large layer of hideous bloat uses whatever makes sense for the specific OS (e.g. signals, GetMessage, threads that poll, ...) to obtain events, and then inserts the events into the event queue (which is created by the same large layer of hideous bloat that is interpreting the javascript).

The OS doesn't know anything about this. It only sees a native process (the large layer of hideous bloat) that's using the functionality the OS provides; and doesn't see the "javascript environment" that the large layer of hideous bloat creates.

Upvotes: 2

Related Questions