Performance, the fetch-execute cycle and interrupts · Performances, le cycle fetch-execute et interruptions
| English | Français |
|---|---|
| interrupt/ˈɪntərʌpt/ | interruption |
| clock speed/klɒk spiːd/ | vitesse d'horloge |
| fetch-execute cycle/fetʃ ˈeksɪkjuːt ˈsaɪkl/ | cycle recherche-exécution |
| cores/kɔːz/ | cœurs |
| cache/kæʃ/ | cache |
| word size/wɜːd saɪz/ | taille de mot |
| port/pɔːt/ | port |
| peripheral/pəˈrɪfərəl/ | périphérique |
| register transfer notation/ˈredʒɪstə ˈtrænsfɜː nəʊˈteɪʃn/ | notation de transfert de registre |
| stack/stæk/ | pile |
| interrupt service routine/ˈɪntərʌpt ˈsɜːvɪs ruːˈtiːn/ | routine de traitement d'interruption |
| interrupt register/ˈɪntərʌpt ˈredʒɪstə/ | registre d'interruption |
Why your laptop drops everything when you press a key
- A processor runs billions of cycles a second. If it had to stop and ask the keyboard "anything yet?" between instructions, it would waste most of them asking.
- Instead the keyboard sends an interrupt 中断. The processor finishes its current instruction, saves its place, deals with the key, and returns as if nothing had happened.
- That one mechanism is how a single processor appears to run your music, your browser and your typing at once.
- This lesson covers what makes a processor fast, how it connects to devices, exactly how it runs one instruction, and how an interrupt cuts in.
Pourquoi votre ordinateur portable tout arrête quand vous appuyez sur une touche
- Un processeur effectue des milliards de cycles par seconde. S'il devait s'arrêter et demander au clavier "quelque chose encore ?" entre les instructions, il gaspillerait la plupart d'entre elles en questions.
- Au lieu de cela, le clavier envoie une interruption 中断. Le processeur termine son instruction actuelle, sauvegarde son emplacement, traite la touche, et revient comme si rien ne s'était passé.
- Ce seul mécanisme explique comment un unique processeur semble exécuter votre musique, votre navigateur et votre frappe simultanément.
- Cette leçon couvre ce qui rend un processeur rapide, comment il se connecte aux périphériques, exactement comment il exécute une instruction, et comment une interruption coupe le fil.
What affects performance
- Clock speed 时钟频率: more fetch-execute cycles a second, so more instructions a second, until heat sets the limit.
- Number of cores 核心: each core fetches and executes its own instruction at the same time, so several programs or threads run in parallel. A program must be written to use them, so doubling the cores does not double the speed.
- Bus width: a wider data bus moves more bits per transfer, so fewer transfers; a wider address bus reaches more memory.
- Cache 高速缓存: a small, fast memory next to the processor holding the instructions and data used most recently, so fewer slow trips to RAM. Word size 字长, the amount of RAM and the storage type help too.
Ce qui affecte les performances
- Vitesse d'horloge 时钟频率 : plus de cycles de récupération-exécution par seconde, donc plus d'instructions par seconde, jusqu'à ce que la chaleur impose une limite.
- Nombre de cœurs 核心 : chaque cœur récupère et exécute sa propre instruction en même temps, permettant à plusieurs programmes ou threads de s'exécuter en parallèle. Un programme doit être écrit pour les utiliser, donc doubler les cœurs ne double pas la vitesse.
- Largeur du bus : un bus de données plus large transporte plus de bits par transfert, réduisant le nombre de transferts ; un bus d'adresse plus large accède à plus de mémoire.
- Cache 高速缓存 : une petite mémoire rapide à côté du processeur contenant les instructions et données les plus récemment utilisées, réduisant les allers-retours lents vers la RAM. La taille de mot 字长, la quantité de RAM et le type de stockage aident également.
Select all · tout the factors that affect CPU performance. · Sélectionnez toutes les facteurs qui affectent les performances du CPU.
Clock speed, cores and cache (plus word size, RAM, storage and bus width) all affect performance. The case colour does not. · Vitesse d'horloge, cœurs et cache (plus taille de mot, RAM, stockage et largeur de bus) affectent toutes les performances. La couleur du boîtier non.
A multi-core CPU is especially helpful for: · Un CPU multi-cœur est particulièrement utile pour :
Extra cores run tasks in parallel. A purely single-threaded job benefits more from higher per-core speed. · Des cœurs supplémentaires exécutent des tâches en parallèle. Un job purement single-threaded tire davantage profit d'une vitesse plus élevée par cœur.
____ memory is a small, fast store next to the processor that holds recently used instructions and data, so fewer slow trips to RAM are needed. · ____ mémoire est un petit stockage rapide à côté du processeur qui contient les instructions et données récemment utilisées, afin de réduire les voyages lents vers la RAM.
More cache means more of the working set sits next to the processor, which is the reason it appears in every performance comparison. · Plus de cache signifie plus du jeu de travail situé à côté du processeur, ce qui explique pourquoi il apparaît dans chaque comparaison de performances.
Worked example: "explain why the new computer is faster"
- Compare the two specifications line by line, each with its reason.
- 3.8 GHz against 2.4 GHz: more cycles a second, so more instructions executed a second.
- 8 cores against 4: twice as many instructions can be fetched and executed at the same time, for software that uses them.
- 16 MB of cache against 4 MB: more of the working set is held next to the processor, so fewer waits for RAM. Each line is two marks: the factor and its consequence.
Exemple résolu : "expliquer pourquoi l'ordinateur neuf est plus rapide"
- Comparer les deux spécifications ligne par ligne, chacune avec sa raison.
- 3.8 GHz contre 2.4 GHz : plus de cycles par seconde, donc davantage d'instructions exécutées par seconde.
- 8 cœurs contre 4 : deux fois plus d'instructions peuvent être récupérées et exécutées en même temps, pour le logiciel qui les utilise.
- 16 Mo de cache contre 4 Mo : plus du jeu de travail est maintenu à côté du processeur, réduisant les attentes pour la RAM. Chaque ligne vaut deux points : le facteur et sa conséquence.
Ports
- A port 端口 is a physical socket that connects a peripheral 外围设备.
- USB (Universal Serial Bus) is general-purpose: keyboards, drives, phones. It is plug-and-play: the computer detects the device, identifies it, loads its driver and can power it, with no restart.
- HDMI (High Definition Multimedia Interface) carries digital video and audio down one cable, so nothing is converted to analogue and the picture is not degraded. VGA (Video Graphics Array) is the older analogue video socket.
Ports
- Un port 端口 est une prise physique qui connecte un périphérique 外围设备.
- USB (Universal Serial Bus) est polyvalent : claviers, disques, téléphones. C'est hot-plug : l'ordinateur détecte le périphérique, l'identifie, charge son pilote et peut l'alimenter, sans redémarrage.
- HDMI (High Definition Multimedia Interface) transporte la vidéo numérique et audio via un seul câble, évitant toute conversion analogique et dégradant l'image. VGA (Video Graphics Array) est l'ancien connecteur vidéo analogique.
Match each port to what it carries. · Associez chaque port à ce qu'il transporte.
Different signals, different sockets: an HDMI cable will not fit a USB port. · Signaux différents, prises différentes : un câble HDMI ne rentre pas dans un port USB.
The fetch stage
- Once per instruction the processor runs the fetch-execute cycle 取指-执行周期. Fetch comes first, and the exam wants it in register transfer notation 寄存器传送记法.
- A read signal travels on the control bus, the address on the address bus, and the instruction comes back on the data bus. The PC is incremented straight after its address is copied, so that a jump executed later can still overwrite it.
PC → MAR → memory → MDR → CIR, with the PC incremented on the way
La phase de récupération
- Une fois par instruction, le processeur exécute le cycle de récupération-exécution 取指-执行周期. La récupération vient en premier, et l'examen exige la notation de transfert de registre 寄存器传送记法.
MAR ← [PC] the address of the next instruction goes to the MAR
PC ← [PC] + 1 the PC now points to the following instruction
MDR ← [[MAR]] the instruction at that address is read into the MDR
CIR ← [MDR] the instruction is copied into the CIR for decoding
- Un signal de lecture parcourt le bus de contrôle, l'adresse sur le bus d'adresse, et l'instruction revient sur le bus de données. Le PC est incrémenté immédiatement après la copie de son adresse, afin qu'un saut exécuté ultérieurement puisse toujours l'écraser.

PC → MAR → mémoire → MDR → CIR, avec l'incrémentation du PC en chemin
Put the fetch steps in the correct order. · Placez les étapes du fetch dans le bon ordre.
PC → MAR, increment PC, read signal, then the instruction travels MDR → CIR ready to decode. · PC → MAR, incrémentation PC, signal de lecture, puis l'instruction voyage MDR → CIR prête à être décodée.
The PC is incremented during the fetch stage so the next cycle fetches the following instruction. · Le PC est incrémenté pendant la phase de fetch pour que le cycle suivant cherche l'instruction suivante.
Incrementing the PC early means it already points at the next instruction by the time this one executes (unless a jump changes it). · Incrémenter le PC tôt signifie qu'il pointe déjà vers l'instruction suivante au moment où celle-ci s'exécute (sauf si un saut le modifie).
Decode, execute, repeat
- Decode: the control unit works out from the instruction in the CIR which operation it is and where its operands are.
- Execute: arithmetic and logic go to the ALU with the result in the ACC; a load or store moves data between memory and a register; a jump writes a new address into the PC.
- Then the cycle repeats from
MAR ← [PC]. At the end of every cycle the processor also checks whether an interrupt is waiting.
One LOAD and one ADD walk the registers: fetch, decode, execute, repeat
Décode, exécute, répéter
- Décode : l'unité de contrôle détermine à partir de l'instruction dans le CIR quelle opération elle est et où se trouvent ses opérandes.
- Exécute : arithmétique et logique vont à l'ALU avec le résultat dans l'ACC ; un chargement ou un stockage déplace des données entre mémoire et registre ; un saut écrit une nouvelle adresse dans le PC.
- Ensuite, le cycle recommence à
MAR ← [PC]. À la fin de chaque cycle, le processeur vérifie également s'une interruption est en attente.
Un LOAD et un ADD parcourent les registres : fetch, decode, execute, repeat
The fetch-execute cycle · Le cycle fetch-execute
Tap round the loop the CPU repeats billions of times a second. Watch how fetch uses the PC/MAR/MDR/CIR registers, then decode and execute act on what was fetched. · Tapez autour de la boucle que le CPU répète des milliards de fois par seconde. Regardez comment le fetch utilise les registres PC/MAR/MDR/CIR, puis comment le decode et l'execute agissent sur ce qui a été cherché.
Worked example: executing two instructions in notation
- Execute
LDD 200(load the contents of address 200 into the ACC):MAR ← 200, thenMDR ← [[MAR]], thenACC ← [MDR]. - Execute
ADD 201:MAR ← 201,MDR ← [[MAR]],ACC ← [ACC] + [MDR]. - Execute
STO 202:MAR ← 202,MDR ← [ACC],[[MAR]] ← [MDR]. - Every line moves one value between two places. The double brackets always mean "the memory location whose address is in the MAR".
Exemple résolu : exécution de deux instructions en notation
- Exécuter
LDD 200(charger le contenu de l'adresse 200 dans l'ACC) :MAR ← 200, puisMDR ← [[MAR]], puisACC ← [MDR]. - Exécuter
ADD 201:MAR ← 201,MDR ← [[MAR]],ACC ← [ACC] + [MDR]. - Exécuter
STO 202:MAR ← 202,MDR ← [ACC],[[MAR]] ← [MDR]. - Chaque ligne déplace une valeur entre deux emplacements. Les doubles crochets signifient toujours "l'emplacement mémoire dont l'adresse est dans MAR".
Put the register transfers that execute LDD 200 in order. · Placez les transferts de registres qui exécutent LDD 200 dans l'ordre.
Address to the MAR, contents of that address to the MDR, then into the accumulator. · Adresse vers le MAR, contenu de cet emplacement vers le MDR, puis vers l'accumulateur.
Interrupts
- An interrupt is a signal that pauses the normal cycle so the processor can deal with an urgent event.
- Causes: a hardware device (a key pressed, a printer buffer empty, a network packet arriving), a software fault (division by zero, an illegal instruction, arithmetic overflow), the operating system's timer marking the end of a time slice, a power-failure warning.
- Interrupts let the system respond promptly without the processor constantly checking devices, and they are how the operating system multitasks.
The cycle, with the interrupt check at the end of each pass
Interrupts
- Une interruption est un signal qui pause le cycle normal pour que le processeur puisse gérer un événement urgent.
- Causes : un périphérique matériel (une touche pressée, un tampon d'imprimante vide, un paquet réseau arriving), une erreur logicielle (division par zéro, instruction illégale, dépassement arithmétique), le minuteur du système d'exploitation marquant la fin d'une tranche de temps, une alerte de panne de courant.
- Les interruptions permettent au système de répondre rapidement sans que le processeur vérifie constamment les périphériques, et c'est ainsi que le système d'exploitation gère le multitâche.

Le cycle, avec la vérification des interruptions à la fin de chaque passage
An interrupt is: · Une interruption est :
An interrupt temporarily pauses the fetch-execute cycle so the CPU can service an urgent event, then resumes. · Une interruption suspend temporairement le cycle fetch-execute afin que le CPU puisse traiter un événement urgent, puis reprend.
Which of these can cause an interrupt? Select all · tout that apply. · Lequel de ces éléments peut provoquer une interruption ? Sélectionnez tous ceux qui s'appliquent.
Hardware events, software faults and the OS timer all raise interrupts. A loop ending is ordinary program flow handled by a jump, not an interrupt. · Les événements matériel, les fautes logicielles et le timer du SOS provoquent des interruptions. La fin d'une boucle est un flux de programme ordinaire géré par une instruction de saut, pas une interruption.
Handling an interrupt
- Finish the current instruction. Save the state: the contents of the PC and the other registers go onto the stack 栈.
- Load the address of the interrupt service routine 中断服务程序 (ISR) into the PC and run it. The ISR handles the event.
- Restore the saved state from the stack and carry on with the interrupted program exactly where it left off.
Save, service, restore, resume
Gestion d'une interruption
- Terminer l'instruction actuelle. Sauvegarder l'état : le contenu du PC et des autres registres sont mis sur la pile 栈.
- Charger l'adresse de la routine de service d'interruption 中断服务程序 (ISR) dans le PC et l'exécuter. L'ISR gère l'événement.
- Restaurer l'état sauvegardé depuis la pile et continuer avec le programme interrompu exactement là où il s'était arrêté.

Save, service, restore, resume
When an interrupt occurs, the CPU first finishes the current instruction, then: · Lorsqu'une interruption se produit, le CPU termine d'abord l'instruction en cours, puis :
It saves the PC and registers, runs the interrupt service routine, then restores the state and continues where it left off. · Il sauvegarde le PC et les registres, exécute la routine de service d'interruption, puis restaure l'état et reprend là où il était.
Worked example: the four-mark interrupt answer
- Explain how an interrupt from an input device is detected and handled in the fetch-execute cycle.
- The device sends an interrupt signal that sets a flag in the interrupt register 中断寄存器. The processor checks that register at the end of every cycle, after the current instruction has finished executing.
- If a flag is set and the interrupt has a higher priority than the current task, the PC and the other registers are saved on the stack. The address of the ISR is loaded into the PC and the routine runs.
- When it finishes, the registers are restored from the stack and the interrupted program resumes. Four points, in that order.
Exemple résolu : la réponse interrupt de quatre points
- Expliquer comment une interruption provenant d'un périphérique d'entrée est détectée et gérée dans le cycle fetch-execute.
- Le périphérique envoie un signal d'interruption qui définit un drapeau dans le registre d'interruption 中断寄存器. Le processeur vérifie ce registre à la fin de chaque cycle, après que l'instruction actuelle a fini d'être exécutée.
- Si un drapeau est défini et que l'interruption a une priorité supérieure à la tâche actuelle, le PC et les autres registres sont sauvegardés sur la pile. L'adresse de l'ISR est chargée dans le PC et la routine s'exécute.
- Lorsqu'elle se termine, les registres sont restaurés depuis la pile et le programme interrompu reprend. Quatre points, dans cet ordre.
The processor checks for interrupts at the end of every fetch-execute cycle, after the current instruction has finished. · Le processeur vérifie la présence d'interruptions à la fin de chaque cycle fetch-execute, après que l'instruction courante ait terminé.
That timing is what lets the state be saved cleanly: no instruction is ever left half done. · C'est ce timing qui permet de sauvegarder proprement l'état : aucune instruction n'est jamais laissée à moitié terminée.
Marks that slip away
- The PC is incremented during the fetch, not after the execute. Put
PC ← [PC] + 1second, straight afterMAR ← [PC]. - Interrupts are checked at the end of a cycle, never in the middle of an instruction.
- The state goes onto the stack and comes back from it. "The CPU stops" or "the program is lost" is wrong: it resumes exactly where it was.
- More cores do not double the speed; the software has to use them. Say so when comparing specifications.
Pièges qui font perdre des points
- Le PC est incrémenté pendant le fetch, pas après l'exécution. Mettre
PC ← [PC] + 1deuxième, juste aprèsMAR ← [PC]. - Les interruptions sont vérifiées à la fin d'un cycle, jamais en plein milieu d'une instruction.
- L'état va sur la pile et revient de celle-ci. "Le CPU s'arrête" ou "le programme est perdu" est faux : il reprend exactement là où il était.
- Plus de cœurs ne doublent pas la vitesse ; le logiciel doit les utiliser. Le dire lors de la comparaison des spécifications.
You've got it
- performance: clock speed, cores, bus width, cache (plus word size, RAM, storage), each with its consequence
- ports: USB general-purpose and plug-and-play, HDMI digital video and audio, VGA analogue video
- fetch:
MAR ← [PC],PC ← [PC] + 1,MDR ← [[MAR]],CIR ← [MDR]; then decode, execute, repeat - an interrupt is checked at the end of each cycle: save state on the stack, run the ISR, restore, resume
Vous avez compris
- performance : vitesse d'horloge, cœurs, largeur du bus, cache (plus taille de mot, RAM, stockage), chacun avec sa conséquence
- ports : USB polyvalent et plug-and-play, HDMI vidéo et audio numérique, VGA vidéo analogique
- fetch :
MAR ← [PC],PC ← [PC] + 1,MDR ← [[MAR]],CIR ← [MDR]; ensuite decode, execute, repeat - une interruption est vérifiée à la fin de chaque cycle : sauvegarder l'état sur la pile, exécuter l'ISR, restaurer, reprendre