+James Fowkes You did seem a bit nervous. But you also seem like a natural teacher who answers questions very clearly. Talking to a camera is always weird and unnerving to begin with.
- Knock knock! + Who's there? - The interrupting interrupt. + The interru... - Just a sec while I deal with something that's suddenly come up. - ... - Please proceed. + pting Interrupt who?
Goodness! I'm working on a digital art Arduino installation and that attachInterrupt function was EXACTLY what I needed to finish my work. Your timing on this video could not have been more perfect. Thank you kindly!
Interrupts are no longer part of Magic The Gathering. They were initially "faster" than instants, but it lead to a whole lot of confusion, so they were scrapped in favour of a stack system.
Sure it is, you just have to play the interrupts as if they were instants. I believe Counterpell, Power Sink and other cards like them are still being printed as instants.
i remembered the moment, when i was playing video game, dota2 then my friend plugged his usb drive for charging his phone, then its start to say "Hello, Interrupt" i was so angry at that time
interupts were heavely used in 8 bits systems. For example, on a NES or C64 you didn't have to check for collision between sprites, the video chip can cause an interrupt when it draws 2 sprites and they overlap
yeah I spent 20 minutes turning on all the bells just to have to go back and spend another 20 minutes turning them all off. fucking miss the old comment notification too. now I get a giant list of notifications at the top and I have to load the video to respond to anyone.
romanemul1 :: Pointers are to access memory, and are a programming concept, not really a concept these guys will upload on. They cover broader topics. Here's a quick intro to points. On the left side of an equals sign, when declaring the name of a variable, give the variable the asterisk sign to tell the compiler you want to create a pointer (this will create a variable that can store the address of another variable or the value at that location): looks like: int* p = *anotherVar; then, on the other side of the equals sign, the asterisk means "address of" which gives you the literal adress of the variable on the disk: int *myP = *variableAlreadyDeclared the ampersan sign is used on the left side, if you are creating a "reference to" variable. what this does, is mimicks the address and value of another variable: int &referenceVar = myVariable (no asterisk for declaration, only variable name) now, the ampersan on the other side of the equals sign, is for getting the value, at a memory location. so if you get the address in a previous declaration, all you have to do is use the ampersan, and the value from that address will be stored in this variable: recent declaration: int *myPointer = *anotherVariable; new declaration: int myCopiedValue = &(myPointer); This may look very confusing, so go online and see if you can find an in-depth tutorial (I've found many, so it should be too hard)... HOPE THIS HELPED!
CGMe: I think you have it backwards. & is address-of, * is dereference. int x = 4; int* ptr_to_x = &x; // Make a pointer to x int copy_of_x = *ptr_to_x; // Copy the value of x to copy_of_x
I was suspicious of the syntax int* p = * anotherVar and tried to compile under Visual Studio 2015 - Visual C++ 19.0 and failed. As far as I'm aware, the legal syntax for pointer declaration and initialization is int* p = &anotherVar? *anotherVar is not "address of", & is. In using *anotherVar, you are deferencing the pointer i.e. requesting the value pointed to by 'anotherVar'. But since 'anotherVar' isn't even a pointer you'll get compiler warnings. Edit: I also think +romanemul1 request for a video regarding pointers is well justified. After all, we've had search algorithms. Not search as in the broader principles of searching, but Dijkstra's algorithm - a very specific algorithm. Edit 2: I also don't think it's justified to call pointers a concept. We have abstract data types which are by definition concepts. Not pointers?
I said "simpler", not "simple". And I was referring more to the whole system than the processor itself, compared with current systems. But I see you agree with the sentiment, and I'm glad to have lived such times.
Interruptions of interruptions happen in real-life all the time..... You hear a knock at your door, then on the way to your door your kid jumps out in front of you and starts whining.
I didn't quite like the explanation. Interrupts are not only used for things that need to be handled fast. A buttonhandler is also a good example for an interrupt service routine, because if you're only waiting for the user to press a button, you can halt the cpu und save power. Also all that "remembering" what the program was doing before is part of the ISR and not build into the CPU except for the program pointer. Also Interrupts in an ISR are possible. You need to disable them in the ISR yourself. Well, at least on the platforms I know.
its ironic that you interrupted him saying why you dont want an interrupt to an interrupt at the end of the video, kind of wanted to know. But really useful video!
Just a quick FYI that has nothing to do with computers, but the whole point of revolving doors is that the inside and outside are never connected. You need that in some buildings because the air inside is at a different temperature, and due to convection a pressure difference between inside and outside will exist at the bottom and the top of the building.
Yes, it is extremely cool. To keep it simple he left out a bit about returning to the program. The software may decide not to do that right now. It may have all the context information for a different chunk of code and swap to it. This lets you effectively have two programs (or more) on the machine. This is how advanced OSes go back and forth between many tasks to give the effect of them all running.
I find it interesting that an "interrupt" sounds so drastic (and it probably was at the time) but nowadays when processors can execute millions of instructions per second (not even talking about multi core/multi thread stuff) it seems trivial.
1 GHz = 1 billion instructions per second. But you still need interrupts, or you computer would wasting a large chunk of that just checking every possible input.
I don't know how Linux and Mac do it, but Windows actually puts all of the interrupt events into a message queue and sends them to every Window that's listening. Modern operating systems don't give user-mode applications direct access to the interrupts.
No the code as much the application. I'm looking at getting the right type of sensor for my needs... then it will be getting the right code for it. I've done proof of concepts, now to tune the two (software/hardware).
7 ปีที่แล้ว +1
Electronics and computer science guy here, so the offer still stands.
Sorry to say this, but I think you should take care of the broken piece of wire in the middle part of row 15 of your board. May I suggest a pair of tweezers? :) 2:46
So I programmed on an arduino last year but I never used interrupts for button presses because you couldn't debounce them in code...could I have used interrupts anyway?
i wrote my first software sprite ISR in z80 assembler on the zx spectrum in the 80s. the interrupt was in sync with the TVs vertical blank which was at 50hz. good times lol.
EDIT: Scratch that... Seems to be answered in the extra bits... Maybe I should watch the whole video (including the outro) first... :) -What if, during an Interrupt Service Routine, another interrupt appears? Wouldn't you eventually overflow something? :/-
Hand MArshall So a "incoming network info" interior would be placed higher than a "incoming keyboard event" interrupt? What if you have two network cards and one interrupts the other? They all have the same priority :)
it possible, but not recommended/best practice. the ISR should handle as fast as possible their routine. and it should be as simple as retrieving bytes and placing those in an auxiliar buffer to be handle afterwards or so, avoiding possible deadlocks on the code, etc.
Does anyone know if interrupts can get dropped? What happens if the os gets flooded with them in a very short space of time?
ปีที่แล้ว
The interrupt controller tracks all interrupt lines (IRQs). For every interrupt line, a bit is set if an interrupt has been triggered on that line but not yet handled. Thus, the ISR is guaranteed to be executed sooner or later after the triggering event, but not necessarily as many times as the interrupt line was triggered.
I have been an aspiring programmer for a couple years now, and have programmed in several languages, and am currently back to C (for the time being - until I can get an Arduino board), and am also trying to decide on a degree for college. I want to know what type of degree would cover things like this, and allow me to program my own boards.
CGMe You're welcome. Also, speaking of Arduino, if you're tight on money, don't hesitate to get a $5 chines clone from Aliexpress. They hold up well and since Arduino is an open source project designed to bring cheap an easy educational kits to everyone, there aren't any moral issues either (clones are perfectly fine under Arduino's license, as long as they don't use the official logo, that's trademarked). You should only get the official boards if you have the money and want to support the project.
***** They're really nice for beginners because there are easy to use libraries for pretty much anything and tons of tutorials. Also, as an ex-professional embedded system designer I still buy Arduinos because they're a nice all-in-one basic package. The last thing I need when prototyping is messing around with resonators and power circuitry. I don't really use anything from the Arduino ecosystem (I do all the coding in Atmel Studio), I just think they make for neat and cheap dev kits. They're also pretty nice for making extremely simple one-offs that aren't worth making a dedicated PCB for (because you need like one or two extra components beside the Arduino). A $1.50 Pro Mini clone with a sensor directly soldered on beats leaving breadboards all around the place.
What happens, when I have more than 1 interrupt pin? So, if I interrupted my programm with pin 1 and while still in the inerruption routine, Interruption pin 2 fires. Can I interrupt my interruption this way?
Is this related to something which would happen in the 90's? I remember computers freezing, or appearing to freeze, but when you wiggled the mouse they would come back to life.
I think that's more to do with CPU lockout that occurred on OS's such as Windows XP et al (I know XP was available in '01 not in the 90's). I remember my uni lecturer talking about the subject and how XP was notorious for locking the CPU. Since true concurrency was not used or commercially available then also? Unless the OS could handle scheduling effectively, your events, such as mouse clicks, were placed into a queue and not processed immediately - leading to freezing.
usually your interrupt code is small and fast... sometimes you may have time to look up an address and move to a register and that's it... depending on the interrupt, from my exp.
Developers should never get away with polling (in userspace) and sleep() should be banned. Don't get me wrong, I like this video, because the micro-controller perspective -- where you don't have the Operating System handling the actual interrupt -- is a good starting point into the area/problems of asynchronous (inter-process) communication. It would be nice to see a followup showing how kernel and user space work together when handling events, what a mutex/semaphore is and why select()/poll()/epoll() is such a cool system call.
I think that would be a very bad idea, as it's a long arbitrary length. And would cause a lot of bugs for developers. I know Android will throw an ANR (app not responding) if your UI thread takes over 5 seconds to render the next frame. But other threads can sit in the background as long as you want. You may want to sleep a thread for awhile, say in a game where you're randomly spawning items on a timer. There are better ways to do that, but it works.
***** When your program needs to do more than just display/update a clock, i. e. you need to catch some sort of (I/O-)event, using sleep() in a polling loop is wrong. I'm beginning to wonder, whether threads have been invented for X Window developers who didn't know select(). ...
***** I'm beginning to wonder if select was invented for dummies who didn't know how to simply plug their code into the main system loop. /s 1. Threads are much simpler than select, what's wrong with that? 2. Most environments won't let you group all kinds of events into a single select (i.e. you can use select to wait on multiple network sockets, but not on a socket or a key press) and even if they did, the resulting code would be a mess. 3. Select doesn't facilitate preemption. If your program performs some non-trivial computation (like video rendering), it will be completely frozen until that computation finishes. What's that? You want to prepare the next rendering job while the current one is being processed? Tough luck, we removed threads because ***** didn't like them, so you're gonna have to wait.
I did once, it went like this "counter++" it was for a delay thing i was trying to implement with chatgtp's help and it had me incrimenting a counter in the routine, didnt work in the end
No, interrupts are handled by the operating system. But if you set up your VBA program correctly, the OS will trigger an event when the user presses a controller button.
+Kenpachi Zaraki As I understand it, though. It wouldn't really be running multiple threads. It would just be simulating it by _protothreading_, switching back and forth between two sets of instructions.
***** well, Arduino is not one of those systems. And it add complexity on a low performance unit. It is a reason that Multics didn't become a commercial success...
if there are multiple threads then there is thread switching, and if your thread was not the one running then it could have missed the signal. it's not so much about doing multiple things at the same time. it's more about the guarantee of not missing a signal. also by introducing multiple threads it becomes very hard to give guarantees about the time it takes the system to respond (a.k.a. real time). which is a lot of times important for embedded devices
-Please make some efforts for pronunciation , a lot of computerphile viewers are not from an english speaking country and i had a lot of trouble understanding you. Anyway thanks for the efforts- [EDIT] finished the video , it just seems James Fowkes is just not at ease with a camera pointed toward him. With some focus i managed to understand everything .
OK interesting, thank you. I had a uni project which required similar characteristics of the Arduino as was demonstrated in this video. Though as far as I was aware at the time, Arduino had no native programmable interrupts. I relied on polling for demonstration purposes.
Okay, I have a question. What happens if a different interrupt comes in before the first ISR is finished? How do you guarantee that the system won't be locked out by a swamp of constant interrupts?
ปีที่แล้ว +2
There are a few ways, depending on the platform. Typically, interrupts are disabled until the ISR re-enables them (which could happen automatically when the CPU flags are restored when the ISR returns, this is probably the most "atomic" way to do it). Often the ISR also has to tell whatever hardware caused the interrupt that it is done, and that it can now send another interrupt, as the hardware often won't send another interrupt before the previous interrupt has been dealt with. Interrupts may also have priorities. On x86, even if interrupts are enabled on the cpu, the programmable interrupt controller (PIC) will only interrupt any executing ISR (before the ISR has told the PIC that it's done) if the new interrupt is of higher priority.
"Interrupts" are exactly what they sound like: crude mismanagement of task scheduling in an obviously multitask environment, by 'bullying' the CPU into excessive make-work-action-administrative processing resulting in thrashing and clock-heating and ultimately exposure of vulnerabilities culminating in security breaches....
I've never heard of the term "Interrupt". What the programmer in the video seems to describing is Event handling? I take it "Interrupts" are a very low level concept.
Interrupts are what happens in the hardware. Event handling is how the software (higher level languages, and APIs mostly) handles those interrupts. The main difference is that the event handling is not necessarily driven by interrupts, but could be done by polling - your program wouldn't know the difference.
3rd year Electronics engineer here It's actually one of the easiest concepts to understand and apply while studying microcontroller architecture, and we had to do it using Assembly
Azthecx yeah, too confusing. I just learned what an integer was. But I still want to be able to fix my computer. My battery swelled up and it's dead now and I need to have it plugged in for it to work.
At a few points in this video I said "8 bytes" where I meant "8 bits". Damn it all.
I got nervous and talked too fast.
+James Fowkes You did seem a bit nervous. But you also seem like a natural teacher who answers questions very clearly. Talking to a camera is always weird and unnerving to begin with.
don't worry it happens to everyone :D
Don't worry I had the video playing at double speed anyway so I just blamed the fast talking on that. ;)
I hope it's not you who subscribed to feministfrequency channel.
- Knock knock!
+ Who's there?
- The interrupting interrupt.
+ The interru...
- Just a sec while I deal with something that's suddenly come up.
- ...
- Please proceed.
+ pting Interrupt who?
HAHAHAH BEST JOKE OF 2017 OMG VERY FUNNY JOHN
Very funny summary of the video
Give this person a cookie!!!
This is what STI instruction is for
that is literally genius
Goodness! I'm working on a digital art Arduino installation and that attachInterrupt function was EXACTLY what I needed to finish my work. Your timing on this video could not have been more perfect. Thank you kindly!
I love the fact that James actually showed human demonstration of interrupts throughout the video
Show of hands: Who else remembers the days of manually configuring IRQs when installing PC hardware?
I just learnt this yesterday in my OS class. Awesome.
Interrupts are no longer part of Magic The Gathering. They were initially "faster" than instants, but it lead to a whole lot of confusion, so they were scrapped in favour of a stack system.
man i miss the good old "play as an interrupt."
Ze Rubenator The blue countetspell deck i no longer viable eh?
Sure it is, you just have to play the interrupts as if they were
instants. I believe Counterpell, Power Sink and other cards like them
are still being printed as instants.
Add 3 mana of any single color to your mana pool. Tapping this artifact can be played as an interrupt aether revolt is awesome btw
This is a great demonstration. Definitely helped me understand this concept better.
i remembered the moment, when i was playing video game, dota2
then my friend plugged his usb drive for charging his phone, then its start to say "Hello, Interrupt"
i was so angry at that time
interupts were heavely used in 8 bits systems. For example, on a NES or C64 you didn't have to check for collision between sprites, the video chip can cause an interrupt when it draws 2 sprites and they overlap
Unringing all the notification bells, because YT is spamming me.
What's the point of these anyway? "Subscriptions" seems to show all uploads of my subscriptions either way.
yeah I spent 20 minutes turning on all the bells just to have to go back and spend another 20 minutes turning them all off. fucking miss the old comment notification too. now I get a giant list of notifications at the top and I have to load the video to respond to anyone.
I no longer get comment reply notifications anymore
why would you ring all your notification bells?!
5:54 : It very much does not save anything in registers, you push your registers on the stack, build a new stackframe, and then execute your code.
I wish to see video about pointers
romanemul1 :: Pointers are to access memory, and are a programming concept, not really a concept these guys will upload on. They cover broader topics. Here's a quick intro to points.
On the left side of an equals sign, when declaring the name of a variable, give the variable the asterisk sign to tell the compiler you want to create a pointer (this will create a variable that can store the address of another variable or the value at that location): looks like: int* p = *anotherVar;
then, on the other side of the equals sign, the asterisk means "address of" which gives you the literal adress of the variable on the disk: int *myP = *variableAlreadyDeclared
the ampersan sign is used on the left side, if you are creating a "reference to" variable. what this does, is mimicks the address and value of another variable: int &referenceVar = myVariable (no asterisk for declaration, only variable name)
now, the ampersan on the other side of the equals sign, is for getting the value, at a memory location. so if you get the address in a previous declaration, all you have to do is use the ampersan, and the value from that address will be stored in this variable:
recent declaration: int *myPointer = *anotherVariable;
new declaration: int myCopiedValue = &(myPointer);
This may look very confusing, so go online and see if you can find an in-depth tutorial (I've found many, so it should be too hard)... HOPE THIS HELPED!
CGMe: I think you have it backwards. & is address-of, * is dereference.
int x = 4;
int* ptr_to_x = &x; // Make a pointer to x
int copy_of_x = *ptr_to_x; // Copy the value of x to copy_of_x
I was suspicious of the syntax int* p = * anotherVar and tried to compile under Visual Studio 2015 - Visual C++ 19.0 and failed. As far as I'm aware, the legal syntax for pointer declaration and initialization is int* p = &anotherVar?
*anotherVar is not "address of", & is. In using *anotherVar, you are deferencing the pointer i.e. requesting the value pointed to by 'anotherVar'. But since 'anotherVar' isn't even a pointer you'll get compiler warnings.
Edit: I also think +romanemul1 request for a video regarding pointers is well justified. After all, we've had search algorithms. Not search as in the broader principles of searching, but Dijkstra's algorithm - a very specific algorithm.
Edit 2: I also don't think it's justified to call pointers a concept. We have abstract data types which are by definition concepts. Not pointers?
pointers are memory addresses :-) best way to understand pointers is to do some asm :-)
BlinkY what if anotherVar is a pointer to a pointer?
actually, multi-core processors are fairly recent. I remember installing interrupt handlers in ye olde 8086. Those were simpler times indeed...
nothing simple about 8086 but i agree with the sentiment :-)
I said "simpler", not "simple". And I was referring more to the whole system than the processor itself, compared with current systems. But I see you agree with the sentiment, and I'm glad to have lived such times.
Interruptions of interruptions happen in real-life all the time..... You hear a knock at your door, then on the way to your door your kid jumps out in front of you and starts whining.
That's why the interrupts may have relative priorities.
the 500ms "delay" loop, means that the button cannot be read during that 500ms, hence it not always responding, for it was inside the 500ms loop.
Thanks for repeating what was said in the video!
Playfully, congratulations, your Sales Incentive payment confirmation is officially through the magical processing chamber!
I didn't quite like the explanation. Interrupts are not only used for things that need to be handled fast. A buttonhandler is also a good example for an interrupt service routine, because if you're only waiting for the user to press a button, you can halt the cpu und save power. Also all that "remembering" what the program was doing before is part of the ISR and not build into the CPU except for the program pointer.
Also Interrupts in an ISR are possible. You need to disable them in the ISR yourself. Well, at least on the platforms I know.
Nice video, but how does the cpu react with Non-Maskable-Interrupts, when compared to programmable interrupts?
Fantastic. Programming tip videos like this are awesome. I would love to see more of them.
Thanks Sam Porter Bridges
its ironic that you interrupted him saying why you dont want an interrupt to an interrupt at the end of the video, kind of wanted to know. But really useful video!
I miss the days when you could hook interrupts and interact directly with video memory and registers. I don't necessary miss segmented memory, though!
Just a quick FYI that has nothing to do with computers, but the whole point of revolving doors is that the inside and outside are never connected. You need that in some buildings because the air inside is at a different temperature, and due to convection a pressure difference between inside and outside will exist at the bottom and the top of the building.
This is so cool, Im going to the library to get a book on this! Thanks!
Yes, it is extremely cool. To keep it simple he left out a bit about returning to the program. The software may decide not to do that right now. It may have all the context information for a different chunk of code and swap to it. This lets you effectively have two programs (or more) on the machine. This is how advanced OSes go back and forth between many tasks to give the effect of them all running.
Please can you do something on DMA and RTOSes?
I find it interesting that an "interrupt" sounds so drastic (and it probably was at the time) but nowadays when processors can execute millions of instructions per second (not even talking about multi core/multi thread stuff) it seems trivial.
1 GHz = 1 billion instructions per second.
But you still need interrupts, or you computer would wasting a large chunk of that just checking every possible input.
1Ghz = 1 billion cycles per second, instructions can take multiple instructions
@@advice-13 You confused clock cycles per second with instructions per second.
I don't know how Linux and Mac do it, but Windows actually puts all of the interrupt events into a message queue and sends them to every Window that's listening. Modern operating systems don't give user-mode applications direct access to the interrupts.
Thank god for programmers.
Is this the same as an IRQ?
I've been actively using this little bit of function in my Arduino code. :D
Now if only I can get it working... ;)
What are you working on?
Also, if you would like me to, I may be able to assist in locating the error if you share the code. :)
No the code as much the application. I'm looking at getting the right type of sensor for my needs... then it will be getting the right code for it. I've done proof of concepts, now to tune the two (software/hardware).
Electronics and computer science guy here, so the offer still stands.
@ nice
Sorry to say this, but I think you should take care of the broken piece of wire in the middle part of row 15 of your board. May I suggest a pair of tweezers? :) 2:46
So I programmed on an arduino last year but I never used interrupts for button presses because you couldn't debounce them in code...could I have used interrupts anyway?
how do interrupts actually work on the hardware level? wouldn't the cpu need to poll the button anyway to find out if it should interrupt or not?
i wrote my first software sprite ISR in z80 assembler on the zx spectrum in the 80s. the interrupt was in sync with the TVs vertical blank which was at 50hz. good times lol.
EDIT: Scratch that... Seems to be answered in the extra bits... Maybe I should watch the whole video (including the outro) first... :)
-What if, during an Interrupt Service Routine, another interrupt appears? Wouldn't you eventually overflow something? :/-
Victor Tran as long as there is enough RAM to remember the state before each interrupt... it shouldn't be a problem. (I gess, I don't know C)
Hand MArshall So a "incoming network info" interior would be placed higher than a "incoming keyboard event" interrupt? What if you have two network cards and one interrupts the other? They all have the same priority :)
it possible, but not recommended/best practice. the ISR should handle as fast as possible their routine. and it should be as simple as retrieving bytes and placing those in an auxiliar buffer to be handle afterwards or so, avoiding possible deadlocks on the code, etc.
lol I do the same thing no worries
3m0_Wr3ck Good to see it's not just me :D
You made it very easy to understand! Thank you
Does anyone know if interrupts can get dropped? What happens if the os gets flooded with them in a very short space of time?
The interrupt controller tracks all interrupt lines (IRQs). For every interrupt line, a bit is set if an interrupt has been triggered on that line but not yet handled. Thus, the ISR is guaranteed to be executed sooner or later after the triggering event, but not necessarily as many times as the interrupt line was triggered.
Be part of an exclusive interview with the CEO of Binance to gain insights into future developments
I prefer the idea of increasing the buffer size
yes, i also prefer the idea of accommodating the hardware to fit the conceptual ideas
I have been an aspiring programmer for a couple years now, and have programmed in several languages, and am currently back to C (for the time being - until I can get an Arduino board), and am also trying to decide on a degree for college. I want to know what type of degree would cover things like this, and allow me to program my own boards.
Computer engineering/embedded system design is what you want.
Thank you
CGMe You're welcome. Also, speaking of Arduino, if you're tight on money, don't hesitate to get a $5 chines clone from Aliexpress. They hold up well and since Arduino is an open source project designed to bring cheap an easy educational kits to everyone, there aren't any moral issues either (clones are perfectly fine under Arduino's license, as long as they don't use the official logo, that's trademarked). You should only get the official boards if you have the money and want to support the project.
***** They're really nice for beginners because there are easy to use libraries for pretty much anything and tons of tutorials.
Also, as an ex-professional embedded system designer I still buy Arduinos because they're a nice all-in-one basic package. The last thing I need when prototyping is messing around with resonators and power circuitry.
I don't really use anything from the Arduino ecosystem (I do all the coding in Atmel Studio), I just think they make for neat and cheap dev kits.
They're also pretty nice for making extremely simple one-offs that aren't worth making a dedicated PCB for (because you need like one or two extra components beside the Arduino). A $1.50 Pro Mini clone with a sensor directly soldered on beats leaving breadboards all around the place.
What happens, when I have more than 1 interrupt pin? So, if I interrupted my programm with pin 1 and while still in the inerruption routine, Interruption pin 2 fires. Can I interrupt my interruption this way?
3 seconds later in the video... ah ok XD
Is this related to something which would happen in the 90's? I remember computers freezing, or appearing to freeze, but when you wiggled the mouse they would come back to life.
I think that's more to do with CPU lockout that occurred on OS's such as Windows XP et al (I know XP was available in '01 not in the 90's). I remember my uni lecturer talking about the subject and how XP was notorious for locking the CPU. Since true concurrency was not used or commercially available then also? Unless the OS could handle scheduling effectively, your events, such as mouse clicks, were placed into a queue and not processed immediately - leading to freezing.
is it then possible that the delay of 500ms may actually end up being longer than that, in case where the handling of the interrupt takes more time?
usually your interrupt code is small and fast... sometimes you may have time to look up an address and move to a register and that's it... depending on the interrupt, from my exp.
Developers should never get away with polling (in userspace) and sleep() should be banned. Don't get me wrong, I like this video, because the micro-controller perspective -- where you don't have the Operating System handling the actual interrupt -- is a good starting point into the area/problems of asynchronous (inter-process) communication.
It would be nice to see a followup showing how kernel and user space work together when handling events, what a mutex/semaphore is and why select()/poll()/epoll() is such a cool system call.
I would make an exception for a sleep() for over a minute.
I think that would be a very bad idea, as it's a long arbitrary length. And would cause a lot of bugs for developers.
I know Android will throw an ANR (app not responding) if your UI thread takes over 5 seconds to render the next frame. But other threads can sit in the background as long as you want.
You may want to sleep a thread for awhile, say in a game where you're randomly spawning items on a timer. There are better ways to do that, but it works.
***** When your program needs to do more than just display/update a clock, i. e. you need to catch some sort of (I/O-)event, using sleep() in a polling loop is wrong.
I'm beginning to wonder, whether threads have been invented for X Window developers who didn't know select(). ...
***** I'm beginning to wonder if select was invented for dummies who didn't know how to simply plug their code into the main system loop. /s
1. Threads are much simpler than select, what's wrong with that?
2. Most environments won't let you group all kinds of events into a single select (i.e. you can use select to wait on multiple network sockets, but not on a socket or a key press) and even if they did, the resulting code would be a mess.
3. Select doesn't facilitate preemption. If your program performs some non-trivial computation (like video rendering), it will be completely frozen until that computation finishes. What's that? You want to prepare the next rendering job while the current one is being processed? Tough luck, we removed threads because ***** didn't like them, so you're gonna have to wait.
+hellterminator, Do you keep deleting your comments after people reply to them?
Is that a Cinnamon desktop on the Lenovo laptop? Or is it Gnome2/MATE?
how to stop the system interrup manually?in a manner?
pliz
Great video! Thanks for making it :D
if you want to time something, how can you subtract the time taken by interrupts?
Does the "hardware buffer" the guy mentioned at 3:39 refer to the FIFO buffer?
Why not go full event based programming?
Have you ever written an interrupt routine?
I did once, it went like this "counter++" it was for a delay thing i was trying to implement with chatgtp's help and it had me incrimenting a counter in the routine, didnt work in the end
Which model laptop is on the desk there?
Please do video on backpropagation algorithm in neural networks
I think they did. With Dr Mike Pound. Also Welch Labs has a great series on that.
they not
+or linzer Victor Lavrenko here on TH-cam does an excellent series on machine learning. I only wish I had the videos when in uni.
I would have made screenshots of the arduino program for this video.
Are interrupts bond with OS?
Suggestion: instead of putting the cards on top of the videos, why not put the videos down below the cards? You've got plenty of room!
but what if i want more then one interrupt arduino and other chips have only 1 interruption-eble pin
are controller inputs in video games interrupts then?
smegskull yes
Mark King ok. cool. can VBA do interrupts?
No, interrupts are handled by the operating system. But if you set up your VBA program correctly, the OS will trigger an event when the user presses a controller button.
Ow! I never knew Arduino processing supported creating ISRs. I'll have me some of that...
Do you really import Club Mate into the UK? :D
(Box in the upper left corner, 6:20)
that's uncomfortable to watch, and I'm understanding
please, can you make an english subtitle for your videos ? 😢
Wait a minute, did you use Processing on that video ? At around 1 min, that kinda looked like the Processing editor.
surprised there was no mention of pushing and popping the stack
GuildOfCalamity That video has so simple explanation, that it actually gives pretty much no information at all.
Thought about it, decided I should keep it as simple as I could.
Right, you could've blown minds by getting into instruction pointers.
Who else was looking at the green LED and going "what is he talking about, this is not flickering at all?" for a while?
*British* spelling: _programme_
_American_ spelling: program
I'm no expert but isn't there a way of having multiple threads and isn't that more suitable and recognisable by other programmers?
Yes, but not on a tiny microprocessor like the one in an Arduino.
+Kenpachi Zaraki As I understand it, though. It wouldn't really be running multiple threads. It would just be simulating it by _protothreading_, switching back and forth between two sets of instructions.
***** well, Arduino is not one of those systems. And it add complexity on a low performance unit.
It is a reason that Multics didn't become a commercial success...
***** yes, so what?
This video was about that hardware and libraries...
if there are multiple threads then there is thread switching, and if your thread was not the one running then it could have missed the signal. it's not so much about doing multiple things at the same time. it's more about the guarantee of not missing a signal.
also by introducing multiple threads it becomes very hard to give guarantees about the time it takes the system to respond (a.k.a. real time). which is a lot of times important for embedded devices
-Please make some efforts for pronunciation , a lot of computerphile viewers are not from an english speaking country and i had a lot of trouble understanding you. Anyway thanks for the efforts-
[EDIT] finished the video , it just seems James Fowkes is just not at ease with a camera pointed toward him. With some focus i managed to understand everything .
Join us for an exclusive interview with the CEO of Binance for insights into future developments
I'm assuming the interrupt code used in this example was a 3rd party library?
Yeah, Arduino takes care of all of that for you.
OK interesting, thank you. I had a uni project which required similar characteristics of the Arduino as was demonstrated in this video. Though as far as I was aware at the time, Arduino had no native programmable interrupts. I relied on polling for demonstration purposes.
Swift and effective reimbursement
Upvote if you tried to mask non-maskable interrupt.
nice
I like the, title.
Nice Video!
Please add spanish subtitles :(
the only problem i have with my os, is idk how to handle keyboard
Isn't Linux built on interrupts?
David Sullivan Most OSs have a concept of interrupts because they manage complex hardware. It is not OS specific
Okay, I have a question. What happens if a different interrupt comes in before the first ISR is finished? How do you guarantee that the system won't be locked out by a swamp of constant interrupts?
There are a few ways, depending on the platform. Typically, interrupts are disabled until the ISR re-enables them (which could happen automatically when the CPU flags are restored when the ISR returns, this is probably the most "atomic" way to do it). Often the ISR also has to tell whatever hardware caused the interrupt that it is done, and that it can now send another interrupt, as the hardware often won't send another interrupt before the previous interrupt has been dealt with. Interrupts may also have priorities. On x86, even if interrupts are enabled on the cpu, the programmable interrupt controller (PIC) will only interrupt any executing ISR (before the ISR has told the PIC that it's done) if the new interrupt is of higher priority.
In my class we had levels of interrupts, higher levels could cause a nester interrupt but lower levels would be ignored
It seems that some of you like gnome classic :)
"Interrupts" are exactly what they sound like: crude mismanagement of task scheduling in an obviously multitask environment, by 'bullying' the CPU into excessive make-work-action-administrative processing resulting in thrashing and clock-heating and ultimately exposure of vulnerabilities culminating in security breaches....
Would you rather:
-Check the time every second to see if it's time for something
*or*
-Set an alarm for that thing
I haz the same raspberry Pi and the same pinboard :)
Do you still have them
Irony as loading bar at 0:02
oh damn arduinos everywhere!
algo helper comment
The Kripke accent :)
+1 for gnome
Second!
I've never heard of the term "Interrupt". What the programmer in the video seems to describing is Event handling? I take it "Interrupts" are a very low level concept.
Interrupts are what happens in the hardware. Event handling is how the software (higher level languages, and APIs mostly) handles those interrupts. The main difference is that the event handling is not necessarily driven by interrupts, but could be done by polling - your program wouldn't know the difference.
first one!!
Nyson Rizqi cra
First dislike
Thecubeing mann 👎
Why though?
I'm pretty sure you need to be really smart to even kind of understand this. I love trying to fix things on my own, but this is way too smart for me.
3rd year Electronics engineer here
It's actually one of the easiest concepts to understand and apply while studying microcontroller architecture, and we had to do it using Assembly
you need to learn programming and how computers work. Saying "you need to be smart" do to anything is just an excuse
Azthecx yeah, too confusing. I just learned what an integer was. But I still want to be able to fix my computer. My battery swelled up and it's dead now and I need to have it plugged in for it to work.
assalane I am taking a computer science class though.
Ксения Ковалевская ... an integer... are you serious? i honestly think you shut quit this already
This guy looks a bit like ricky gervais...
Hate that guy.