Archived

This topic is now archived and is closed to further replies.

Esap1

Is a Thread the same as an Interupt?

Recommended Posts

No a thread is a discrete sequence (or unit, depending on how you look at it) of execution. An interrupt is a method of signalling the operating system of an event.

Share this post


Link to post
Share on other sites
Some interupts don''t go to the operating system, they go directly to the proessor, and execute the code at the given adress in the interupt vector, howerver, a os may of cource exchange the vector or the code at the given adress.

Share this post


Link to post
Share on other sites
I think this is an easier explanation:

A thread is the same as a process, a calculation of any kind that is sent to the processor. MS Windows calls it threads, UNIX calls them processes. Whenever you run a program, it''s got at least one thread, but if you want several things to happend at the same time (multitasking) you create several threads.

Interrupts (or IRQs) are signals to the processor that the interrupt sender wants attention about something. The computer BIOS manages the IRQ adresses (channels) and if two devices should have the same IRQ adress, they don''t work or they work erroneously or very slow.

============================
Daniel Netz, Sentinel Design
"I'm not stupid, I'm from Sweden" - Unknown

Share this post


Link to post
Share on other sites
During an interupt the processor goes off and executes a totally diferent bit of code (an Interupt Service Routine if I remember rightly), once this code returns, the processor continues where it left off with the program.

With threads, the OS splits program execution up into chunks, and switches between them every so often. This switch is probably performed by an ISR on the Timer Interrupt, so there are similarities between Interrupts (or rather, the code executed by an interrupt, which I think is what you meant) and threads.

Hope I haven''t confused you with my dodgy explanations

George.

"Who says computer games affect kids, imagine if PacMan affected us as kids, we'd all sit around in a darkened room munching pills and listening to repetitive music....uh oh!"

Share this post


Link to post
Share on other sites
quote:
Original post by Spiff

A thread is the same as a process, a calculation of any kind that is sent to the processor. MS Windows calls it threads, UNIX calls them processes. Whenever you run a program, it''s got at least one thread, but if you want several things to happend at the same time (multitasking) you create several threads.


I think that technically, Windows has both threads and processes (as can UNIX, but it''s less common to use threads since their inter-process communication is mor well-refined.) Each process runs in at least 1 thread, and may optionally use more. Threads share the memory space of their calling process, whereas processes are (supposedly) isolated from each other, and when you try to go outside that space you get your traditional crash, eg. illegal operation in Windows.

Share this post


Link to post
Share on other sites
In Windows, process = application and contains at least 1 thread. That process can spawn more worker or user-interface threads to utilize multithreaded programming techniques.

Share this post


Link to post
Share on other sites
Spiff: IRQs are not interrupts. IRQs are the channels on the PIC, which generates some hardware interrupts. Interrupts are not necessarily generated by hardware, and can be triggered by applications.

Share this post


Link to post
Share on other sites
From what I know, threads are processes that are each alocated a certain percentage of CPU time.
An interrupt is a message that is send to Windows (or DOS, or whatever) after a certain time has passed.

I think this is right. Otherwise, does it really matter if you know the difference in Windows (don''t answer that)!!!

Share this post


Link to post
Share on other sites
Interrupts are generated whenever a certain event occurs that is appropriate to the interrupt type. It is not limited to a "certain time has passed." Examples of interrupts include divide by zero exceptions, NMI, singlestep and breakpoint interrupts.

Share this post


Link to post
Share on other sites
"Spiff: IRQs are not interrupts" - yep, that I know, they''re Interrupt Request channels (it was just a bad explanation from me, I blame the swede in me for that) and every hardware device needs to have one. What I didn''t know was that OS level interrupts was called just interrupts too. IRQ interrupts are the most basic interrupts though.

Bah, this is getting confusing...I think we''ve helped Esap1 though

============================
Daniel Netz, Sentinel Design
"I'm not stupid, I'm from Sweden" - Unknown

Share this post


Link to post
Share on other sites
quote:
Original post by Zipster

From what I know, threads are processes that are each alocated a certain percentage of CPU time.


Not necessarily. Processes only get so much CPU time too. The main difference is that multiple threads share a single process''s memory space (if they couldn''t, they''d be largely useless!) whereas processes are nearly always independent of each other.

Share this post


Link to post
Share on other sites