Thursday, June 6, 2019
Interrupt and a Trap in an Operating System Essay Example for Free
Interrupt and a Trap in an Operating System EssayWhat are the differences among an interrupt and a restrain? What are their importance? According to Stallings (2012) an interrupt is a suspension of a process, such as the execution of a information processing system program, caused by an event external to that process and performed in such a way that the process faeces be resumed (p. 716). Stallings (2012) goes on to say that interrupts are provided in the beginning as a way to improve processor utilization. For example, most I/O devices are much slower than the processor (p. 14). A trap is an unprogrammed qualified jump to a specified address that is automatically activated by hardware the location from which the jump was made is recorded (Stallings, 2012, p. 721). A trap is genuinely a software generated interrupt caused either by an error (for example division by zero, invalid memory access etc.), or by a specific request by an operating(a) system service generated by a user program.Trap is sometimes called Exception. The hardware or software can generate these interrupts. When the interrupt or trap occurs, the hardware transfers control to the operating system which first preserves the current state of the system by deliverance the current CPU registers content and program counters value. Then the focus shifts to the determination of which type of interrupt has occurred. For each type of interrupt, separate segments of code in the operating system determine what action should be taken and thus the system keeps on functioning by executing computational instruction, I/O instruction, warehousing instruction etc. Provide an example of each.Example of an Interrupt retrieved from http//www.scriptoriumdesigns.com/embedded/show_codefile.php?fname=interrupts/AVR_ISR_1.c// AVR_ISR_1include avr/io.hinclude avr/interrupt.htypedef uint8_t u8 // convenient unsigned variable designationstypedef uint16_t u16 pin down INPORT PINDdefine OUTPORT PORTCdefine OUTDD R DDRCvolatile u8 Int_flag = 0ISR( INT0_vect )OUTPORT = 0x01 // toggle LEDvoid int0_init( void )MCUCR = (1ISC01) // enable negative edge on INT0GICR = (1INT0) // enable INT0int main( void )OUTDDR = 0x01 // set bit 0 to outputOUTPORT = 0x01 // set LED off (active low)int0_init() // configure INT0sei() // enable global interruptswhile (1) // loop forever, all work happens in ISRreturn(0)Example of a trap retrieved from http//www.ibm.com/developerworks/aix/library/au-usingtraps/index.html /bin/bashproj_dir=/opt/pcake/bin check file is presentif -f $proj_dir/run_pj thenecho $proj_dir/run_pj not presentexitingexit 1fi quarter a backup copycp -p $proj_dir/run_pj $proj_dir/run_pj.24042011if $? = 0 thenecho $proj_dir/run_pj no backup madeexitingexit 1fi copy over updated fileif -f /opt/ launch/rollout/run_pj thenecho /opt/dump/rollout/run_pj not presentexitingexit 1ficp -p /opt/dump/rollout/run_pj $proj_dir/run_pjif $? = 0 thenecho $proj_dir/run_pj was not copied..exitingexit 1fiRe ferencesStallings, W. (2012). Operating systems Internals and design principles (7th ed.). Boston, MA Prentice Hall.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment