0

I'm reading about event loops that pass messages, as I have to design one for a project I am working on. To understand it better, I am trying to analogize it to other things that I know somewhat better, to aid my understanding. Is the fetch / execute cycle of a CPU comparable at all to the event loop software construct? If not, what is the main difference (besides one being directly stored in hardware, of course). Thank you.

2
  • What do you mean by message loops? Do you mean event loops?
    – Barmar
    Jul 24, 2013 at 13:56
  • yes, i think so. will edit.
    – Seb Silver
    Jul 24, 2013 at 14:10

1 Answer 1

0

No, the two are not really similar.

In an event loop, the system has a queue that it reads from, and other processes can add items to the queue. These items are called messages or events, and they trigger action by the processor. Often the system allows multiple readers to wait on the queue, and they can register which types of events they're interested in, and the main event loop module doles them out appropriately.

The CPU fetch/execute cycle simply steps sequentially through memory, reading each instruction (fetch) and performing the appropriate action (execute).

The main difference is that events can be added to the event queue asynchronously, while fetch/execute is synchronous.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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