farjmp(0, 4 * 8);
这是一个far跳转,先看一下farjmp的实现:
_farjmp: ; void farjmp(int eip, int cs) JMP FAR [ESP+4] ; eip, cs RET
set_segmdesc(gdt + 4, 103, (int) &tss_b, AR_TSS32);
void task_b_main(struct SHEET *sht_back) { //for (;;) { io_hlt(); } struct FIFO32 fifo; struct TIMER *timer_ts, *timer_put; int i, fifobuf[128], count = 0; char s[11]; fifo32_init(&fifo, 128, fifobuf); timer_ts = timer_alloc(); timer_init(timer_ts, &fifo, 2); timer_settime(timer_ts, 2); timer_put = timer_alloc(); timer_init(timer_put, &fifo, 1); timer_settime(timer_put, 1); for (;;) { count++; io_cli(); if (fifo32_status(&fifo) == 0) { //io_stihlt(); io_sti(); } else { i = fifo32_get(&fifo); io_sti(); if (i == 1) { // each 0.01s refreshing the screen, not each count++, enhancing the performance sprintf(s, "%11d", count); putfonts8_asc_sht(sht_back, 0, 144, COL8_FFFFFF, COL8_0000FF, s, 11); timer_settime(timer_put, 1); } else if (i == 2) { farjmp(0, 3 * 8); timer_settime(timer_ts, 2); } } } }
30天自制操作系统之第15天 多任务(1),布布扣,bubuko.com
原文地址:http://blog.csdn.net/bluecloudmatrix/article/details/38585053