Ағылшыншамен салыстырыңыз: абзацты басыңыз — түпнұсқа терезеде ашылады. Абзац астындағы EN түймесі оны мәтін ішінде көрсетеді.
Мазмұны
Кіріспе
Компьютердің негізгі жұмыс циклы
Basic operation cycle of a computer
Нұсқау циклы (сондай-ақ, іздеу-декодтау-орындау циклы немесе жай ғана іздеу-орындау циклы деп аталады) – орталық процессордың (CPU) компьютерді қосудан бастап, өшіруге дейін нұсқауларды өңдеу үшін орындалатын циклы. Ол үш негізгі кезеңнен тұрады: іздеу кезеңі, декодтау кезеңі және орындау кезеңі. Қарапайым процессорларда нұсқау циклы тізбектеп орындалады, әрбір нұсқау келесісі басталар алдында өңделеді. Көптеген қазіргі заманғы процессорларда нұсқау циклдары синхронды түрде, көбінесе параллельді түрде, нұсқау құбыры арқылы орындалады: келесі нұсқау алдыңғы нұсқау аяқталмас бұрын өңделе бастайды, бұл цикл жеке қадамдарға бөлінгендіктен мүмкін болады.
The instruction cycle (also known as the fetch–decode–execute cycle, or simply the fetch execute cycle) is the cycle that the central processing unit (CPU) follows from boot up until the computer has shut down in order to process instructions. It is composed of three main stages: the fetch stage, the decode stage, and the execute stage. In simpler CPUs, the instruction cycle is executed sequentially, each instruction being processed before the next one is started. In most modern CPUs, the instruction cycles are instead executed concurrently, and often in parallel, through an instruction pipeline: the next instruction starts being processed before the previous instruction has finished, which is possible because the cycle is broken up into separate steps.
Құралымдардың рөлі
Бағдарлама санағы (ПК) – орындалатын келесі нұсқаудың жад мекенжайын сақтайтын арнайы тіркегіш. Алу кезеңінде ПК-де сақталған мекенжай жад адресі тіркегішіне (MAR) көшіріледі, содан кейін ПК келесі орындалатын нұсқаудың жад мекенжайына "нұсқау" беру үшін арттырылады. Процессор содан кейін MAR-да сипатталған жад мекенжайы бойынша нұсқауды алады және оны жад деректері тіркегішіне (MDR) көшіреді. MDR жадтан алынған деректерді немесе жадқа сақталуын күтіп тұрған деректерді сақтайтын екі бағытты тіркегіш ретінде де әрекет етеді (осы себепті ол жад буферлік тіркегіші (MBR) деп те аталады). Соңында, MDR-дегі нұсқау қазіргі нұсқау тіркегішіне (CIR) көшіріледі, ол жадтан алынған нұсқауды уақытша сақтайды. Декодтау кезеңінде басқару блогы (ББ) CIR-дегі нұсқауды декодтайды. ББ содан кейін процессордың басқа компоненттеріне, мысалы, арифметикалық-логикалық құрылғыға (АЛҚ) және қозғалатын нүктелік құрылғыға (ҚНҚ) сигналдар жібереді. АЛҚ қосу, алу сияқты арифметикалық операцияларды, сондай-ақ қайта-қайта қосу арқылы көбейту және қайта-қайта алу арқылы бөлуді орындайды. Ол сонымен қатар AND, OR, NOT және бинарлық ығысулар сияқты логикалық операцияларды орындайды. ҚНҚ қозғалатын нүктелік операцияларды орындау үшін арналған.
The program counter (PC) is a special register that holds the memory address of the next instruction to be executed. During the fetch stage, the address stored in the PC is copied into the memory address register (MAR) and then the PC is incremented in order to "point" to the memory address of the next instruction to be executed. The CPU then takes the instruction at the memory address described by the MAR and copies it into the memory data register (MDR). The MDR also acts as a two way register that holds data fetched from memory or data waiting to be stored in memory (it is also known as the memory buffer register (MBR) because of this). Eventually, the instruction in the MDR is copied into the current instruction register (CIR) which acts as a temporary holding ground for the instruction that has just been fetched from memory. During the decode stage, the control unit (CU) will decode the instruction in the CIR. The CU then sends signals to other components within the CPU, such as the arithmetic logic unit (ALU) and the floating point unit (FPU). The ALU performs arithmetic operations such as addition and subtraction and also multiplication via repeated addition and division via repeated subtraction. It also performs logic operations such as AND, OR, NOT, and binary shifts as well. The FPU is reserved for performing floating point operations.
Іске қосу
Цикл жүйеге қуат қосылғанда басталады, жүйе архитектурасымен алдын ала анықталған бастапқы PC мәнімен. Мысалы, Intel IA 32 процессорларында алдын ала анықталған PC мәні 0xfffffff0 болып табылады. Әдетте, бұл мекенжай тек оқуға арналған жадта (ROM) сақталған нұсқаулар жиынтығына сілтеме жасайды, ол операциялық жүйені жүктеу (немесе қосу) процесін бастайды.
The cycle begins as soon as power is applied to the system, with an initial PC value that is predefined by the system's architecture (for instance, in Intel IA 32 CPUs, the predefined PC value is 0xfffffff0). Typically, this address points to a set of instructions in read only memory (ROM), which begins the process of loading (or booting) the operating system.
Декодтау кезеңі
Декодтау процесі процессорға орындалуға тиіс нұсқауды анықтауға мүмкіндік береді, соның арқасында CPU нұсқауды орындау үшін қанша операндты алу керектігін біледі. Жадтан алынған опкод келесі қадамдар үшін декодталады және тиісті тіркелгілерге (регистрлерге) жылжытылады. Декодтау әдетте CPU-ның басқару блогындағы екілік декодерлермен жүзеге асырылады.
The decoding process allows the processor to determine what instruction is to be performed so that the CPU can tell how many operands it needs to fetch in order to perform the instruction. The opcode fetched from the memory is decoded for the next steps and moved to the appropriate registers. The decoding is typically performed by binary decoders in the CPU's control unit.
Нақты мекенжайын оқу
Бұл қадамда орындалатын операцияның түрі анықталады. Егер ол жад операциясы болса, компьютер оның тікелей немесе жанама жад операциясы екенін тексереді:
Тікелей жад операциясы – Ешқандай әрекет жасалмайды. Жанама жад операциясы – Тиімді мекенжай жадтан оқылады. Егер ол кіріс-шығыс немесе регистрлік нұсқау болса, компьютер оның түрін тексереді және нұсқауды орындайды.
This step evaluates which type of operation is to be performed. If it is a memory operation, the computer checks whether it's a direct or indirect memory operation:
Direct memory operation – Nothing is done. Indirect memory operation – The effective address is read from memory. If it is an I/O or register instruction, the computer checks its type and executes the instruction.
Орындау кезеңі
CPU кодталған нұсқауды басқару сигналдары жиынтығы ретінде тиісті компьютер компоненттеріне жібереді. Егер нұсқау арифметикалық немесе логикалық операцияларды қамтитын болса, ALU пайдаланылады. Бұл нұсқау циклінің соңғы пайдаланушы үшін пайдалы жалғыз кезеңі. Қалғанның бәрі орындалу қадамын жүзеге асыру үшін қажетті қосымша жұмыс.
The CPU sends the decoded instruction as a set of control signals to the corresponding computer components. If the instruction involves arithmetic or logic, the ALU is utilized. This is the only stage of the instruction cycle that is useful from the perspective of the end user. Everything else is overhead required to make the execute step happen.