0

I got started with programming back in the DOS days. One of my early projects involved overriding the keyboard interrupt service routine with my own. Now I'm trying out NodeJS to update myself, and I feel there is a similarity between the non-blocking design of NodeJS and my old experience with interrupt service routines (ISR). My guess is the similarity would be the keyboard ISR would wait for a key press input signal from the keyboard, while NodeJS waits for a web request. When the input arrives, both NodeJS and the ISR need to hurry to handle the request and say they're done in case a new input arrives. That is, there is a penalty for a CPU bound task slowing down the next web response or the next keyboard key input. Is this observation a reasonable understanding? I'm new to NodeJS so perhaps I'm missing an important difference or just incorrect in some fundamental way.

2

Sort of.

Interrupt Service Routines are really just hardware hooks so that the keyboard or other hardware device can make a subroutine call to the operating system while maintaining a degree of isolation. There's a lot more to it, of course, and if the method appears to be asynchronous, it's only because operating systems back then were capable of rudimentary task switching, or maybe even cooperative multitasking.

Node.JS's mechanism of operation is a bit different. Node.JS has an event loop that receives requests, each of which it assigns to a new thread under the covers. An async handler is registered to receive the eventual result of the requests. Everything happens at a much higher level of abstraction.

  • How are Node.JS apps different (or claimably efficient) from Tomcat applications as both of them use an underlying thread pool to process requests? – zafar142003 Mar 9 '17 at 8:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.