[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

how the HECK do interrupts work. shouldn't they halve the

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 20
Thread images: 9

File: maki is cute 154.jpg (1MB, 1430x1947px) Image search: [Google]
maki is cute 154.jpg
1MB, 1430x1947px
how the HECK do interrupts work. shouldn't they halve the efficiency of any given program? since it has to check if the interrupt is active on every cycle. this isn't covered in the k&r book
>>
File: maki is cute 388.jpg (402KB, 600x600px) Image search: [Google]
maki is cute 388.jpg
402KB, 600x600px
>>
>>59246013
Programs don't check for interrupts.
Your operating system is responsible for managing interrupts.
>>
Interrupts aren't checked for every cycle, they're enabled and disabled. If an interrupt is attempted and blocked then it queues up. If you're a big dick then you can write code that permanently disables interrupts letting you lock a processor. This is generally prevented by some extra permissions.
>>
File: 013359162X.jpg (149KB, 508x648px) Image search: [Google]
013359162X.jpg
149KB, 508x648px
read the book luke
i hope you aren't learning C from k&r, unless you're into bdsm
>>
File: maki is cute 623.png (1MB, 1242x1247px) Image search: [Google]
maki is cute 623.png
1MB, 1242x1247px
>>59246143
i don;t use an operating system im programming an avr (。>﹏<。)

how does it "manage" them without checking every cycle to see if the pin is active?
>>
>>59246172
>If an interrupt is attempted and blocked then it queues up.
Wrong.

When an interrupt occurs, the interrupt line is just simply held high until it is serviced.
If you ignore the interrupt and another interrupt comes in, then you have missed the last interrupt.
That's why you should only disable interrupts for very short amounts of time, so that you only defer the handling of the interrupt rather than missing any.
Interrupts need to be handled as soon as possible or else they're lost.
>>
>>59246186
In that case interrupts are handled in hardware by your processor.
>>
File: maki is cute 1056.jpg (130KB, 600x811px) Image search: [Google]
maki is cute 1056.jpg
130KB, 600x811px
>>59246209
that's what i don't get, though. if it is executing a command, and monitoring for input, how can it do both on the same cycle? it's only got one core
>>
>>59246206
not him but you can "service" an interrupt by picking it up and just dropping it onto a queue, right?

that way you don't lose anything
>>
File: bestgirl.jpg (51KB, 1080x1080px) Image search: [Google]
bestgirl.jpg
51KB, 1080x1080px
>>59246013
>>59246186
>>59246139
This thread will be pruned a couple hours from now when /g/ mods finally wake up

But no, that's not how it works
>>
>>59246228
Yes, you can. But interrupts technically aren't disabled, you're just deferring their handling.
Your queue must be able to insert into some kind of list right? inserting into the list must be atomic, or else another interrupt coming in while you're in the middle of inserting could thoroughly fuck things up.
You obviously can't use a mutex/splinlock in an interrupt handler so the only thing you can do is temporarily disable interrupts while inserting to defer any interrupt that may come in during that time.
>>
>>59246227

It checks your pin every cycle.

>fetch
>decode
>execute
>process interrupts

There aren't any additional costs performance-wise because it's implemented in hardware.
>>
>>59246259
I see, that makes sense. I didn't think about the atomicity requirement, which is important because the CPU can call your interrupt handler anytime.

If the interrupt line gets realy congested and some interrupt requests are lost, do those hardware devices just try again after a set interval?
>>
File: maki is cute 783.jpg (722KB, 2267x3474px) Image search: [Google]
maki is cute 783.jpg
722KB, 2267x3474px
>>59246305
ah ha. so checking that pin for input is part of the processor's architecture? i guess that functionality just isn't used if you have that pin defined as an output?
>>
>>59246371
cute tomato knees !!!
>>
>>59246013
Maki too fat in this picture. Delet- this
>>
File: 1479030567735.jpg (65KB, 720x960px) Image search: [Google]
1479030567735.jpg
65KB, 720x960px
>>59246381
I think her sweater is just a bit big anon.
>>
>>59246013
Maki
>>
File: maki is cute 499.jpg (446KB, 472x700px) Image search: [Google]
maki is cute 499.jpg
446KB, 472x700px
>>59246548
maki!
Thread posts: 20
Thread images: 9


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.