您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ tswitch函数代码示例

51自学网 2021-06-03 08:59:58
  C++
这篇教程C++ tswitch函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中tswitch函数的典型用法代码示例。如果您正苦于以下问题:C++ tswitch函数的具体用法?C++ tswitch怎么用?C++ tswitch使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了tswitch函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: kexit

//turns process into zombie. if it has children, all its children go to p1int kexit(int exitValue){	int i;	PROC *p;	for (i = 0; i < NFD; i++)	{		if(running->fd[i] != 0)			close_pipe(i);	}	//send children (dead or alive) to P1's orphanage	for (i = 1; i < NPROC; i++)	{		p = &proc[i];		if(p->status != FREE && p->ppid == running->pid)		{			p->ppid = 1;			p->parent = &proc[1];		}	}	//restore name string	strcpy(running->name, pname[running->pid]);	//record exitValue and become a ZOMBIE	running->exitCode = exitValue;	running->status = ZOMBIE;	//wakeup parent and P1	kwakeup(running->parent);	kwakeup(&proc[1]);	tswitch();}
开发者ID:lldarrow,项目名称:CptS-460-Operating-Systems,代码行数:34,


示例2: ksleep

//stops process to wait for an eventint ksleep(int event){	running->status = SLEEP; // change status to SLEEP	running->event = event;  // record event in PROC.event	enqueue(&sleepList, running);//enter sleepList	tswitch();               // give up CPU, switch process}
开发者ID:lldarrow,项目名称:CptS-460-Operating-Systems,代码行数:8,


示例3: kcinth

/****************** syscall handler in C ***************************/int kcinth(){	u16    segment, offset;	int    a,b,c,d, r;	segment = running->uss;	offset = running->usp;	/** get syscall parameters from ustack **/	a = get_word(segment, offset + 2*PA);	b = get_word(segment, offset + 2*PB);	c = get_word(segment, offset + 2*PC);	d = get_word(segment, offset + 2*PD);	//printf("proc%d syscall a=%d b=%d c=%d d=%d/n", running->pid, a,b,c,d);	switch(a){		case 0 : r = running->pid;     break;		case 1 : r = do_ps();          break;		case 2 : r = chname(b);        break;		case 3 : r = kmode();          break;		case 4 : r = tswitch();        break;		case 5 : r = do_wait(b);       break;		case 6 : r = do_exit(b);       break;		case 90: r =  getc();          break;		case 91: r =  putc(b);         break;		case 99: do_exit(b);           break;		default: printf("invalid syscall # : %d/n", a);	}	put_word(r, segment, offset + 2*AX);}
开发者ID:bhanderson,项目名称:cpts460,代码行数:31,


示例4: body

int body(void){   char c, str[64];   printf("proc %d resumes to body()/n/r", running->pid);   showLists();   while(1)   {      printf("/rproc %d running : enter a key [s|f|z|a|w|q|u|p|l]: ", running->pid);      c = getc();      printf("%c/n/r", c);      switch(c)      {         case 's': tswitch();  break;         case 'q': do_exit();  break;         case 'f': kfork("/bin/u1");    break;         case 'z': do_sleep(); break;         case 'a': do_wake();  break;         case 'w': do_wait();  break;         case 'u': goUmode();  break;         case 'p': do_ps();    break;         case 'l': showLists();break;         default: break;      }   }}
开发者ID:Cj-muse,项目名称:Lab4,代码行数:26,


示例5: my_exit

//changes running process status to ZOMBIE, then calls tswitch() to give up CPUint my_exit(){	printf("process [%d] is now a zombie/n", running->pid);	running->status = ZOMBIE;	tswitch();	return 0;}
开发者ID:lldarrow,项目名称:CptS-460-Operating-Systems,代码行数:8,


示例6: main

//main function, execution starts heremain(){    int i = 0;    vid_init();//initialize video    printf("MTX starts in main()/n");    init(); // initialize and create P0 as running    set_vector(80, int80h);    kfork("/bin/u1");     // P0 kfork() P1    set_vector(9, kbinth);    kbd_init();    //timer init    lock();    set_vector(8,tinth);    timer_init();    while(1)    {      unlock();      if(readyQueue)          tswitch();      else          halt();   }}
开发者ID:lldarrow,项目名称:CptS-460-Operating-Systems,代码行数:29,


示例7: main

main(){ /* initialize(); PROC p[5]; int i=0; for(i=0;i<5;i++){  p[i].priority = i;  p[i].pid = 5-i;  enqueue(&p[i], &readyQueue); }*/  printf("/nWelcome to the 460 Multitasking System/n");    initialize();    printf("P0 forks P1/n");  kfork();  // fork P1   printf("P0 switches to P1... calling tswitch()/n");     tswitch();  // switches running to P1  // Switch, Quit & Fork processes until all of them are dead except P0  printf("Almost done... running is P%d/n", running->pid);   printf("P0 resumes: all dead, happy ending/n"); // printf("Lets go to the %s to get %d %s for %d %ss/n", "store", 5, "steaks", 8, "dinner");}
开发者ID:shank8,项目名称:CS460,代码行数:28,


示例8: kexit

int kexit(int exitValue){	int i, wakeupP1 = 0;	PROC *p;	if (running->pid == 1 && nproc > 2 ){ //nproc = number of active PROCS		printf("other procs still exist, P1 can't die yet/n");		return -1;	}	/* send children (dead or alive) to P1's orphanage */	for (i = 1; i < NPROC; i++){		p = &proc[i];		if(p->status != FREE && p->ppid == running->pid){			p->ppid = 1;			p->parent = &proc[1];			wakeupP1++;		}	}	/*record exitValue and become a ZOMBIE */	running->exitCode = exitValue;	running->status = ZOMBIE;		/*wakeup parent and also P1 if necessary */	kwakeup(running->parent); //parent sleeps on its PROC address	if(wakeupP1){		kwakeup(&proc[1]);	}	tswitch(); //give up CPU	return 0;}
开发者ID:KHAAAAN,项目名称:operating_systems_in_C,代码行数:30,


示例9: body

int body(){ char c;int event;while(1){	printf("/n***************************************/n");	print();	printf("/nI am task %d My parent=%d/n", running->pid, running->ppid);	printf("input a char [fork:f|switch:s|exit:q|sleep:z|wakeup:a|wait:w] : ");  	c = getchar();	switch(c){		case 'f': kfork();      break;		case 's': tswitch();    break;		case 'q': kexit(0); 	break;		case 'z': {printf("enter event to put process to sleep");			  scanf("%d",&event);					  ksleep(event);}				  break;		case 'a': {printf("enter event to wake up process");			  scanf("%d",&event);					  kwakeup(event);}				  break;		case 'w': kwait(0); 	break;		default: printf("invalid char/n"); break;		}		}return;}
开发者ID:ramyyahari,项目名称:CPTS_560,代码行数:28,


示例10: kexit

int kexit(int exitValue) {    int i, wakeupP1 = 0;    PROC *p;    if(running->pid==1 && nproc > 2) {        printf("other procs still exist, P1 can't die yet/n");        return -1;    }    //give children to p1    for(i = 1; i < NPROC; i++) {        p = &proc[i];        if(p->status != FREE && p->ppid == running->pid) {            p->ppid = 1;            p->parent = &proc[1];            wakeupP1++;        }    }    //record exitValue and become a Zome    running->status = ZOMBIE;    running->exitCode = exitValue;    kwakeup(running->parent); //wake up parent if sleep to tell them you died //parrent sleep    //wakeup parent    if(wakeupP1) {        kwakeup(&proc[1]);    }    tswitch();}
开发者ID:tymicruz,项目名称:CuatroSeisZero,代码行数:33,


示例11: kcinth

/************** syscall routing table ***********/int kcinth() {  u16 x, y, z, w, r;   u16 seg, off;  seg = running->uss; off = running->usp;  x = get_word(seg, off+13*2);  y = get_word(seg, off+14*2);  z = get_word(seg, off+15*2);  w = get_word(seg, off+16*2);     switch(x){       case 0 : r = running->pid;    break;       case 1 : r = kps();           break;       case 2 : r = chname(y);       break;       case 3 : r = kmode();         break;       case 4 : r = tswitch();       break;       case 5 : r = kwait();         break;       case 6 : r = kexit();         break;       case 7 : r = fork();          break;       case 8 : r = kexec(y);        break;       case 9 : r = sout(y); break;       case 10: r = sin(y); break;       case 99: r = kexit();                break;       default: printf("invalid syscall # : %d/n", x);   }   put_word(r, seg, off+2*8);}
开发者ID:tymicruz,项目名称:CuatroSeisZero,代码行数:34,


示例12: body

// figure out what the user wants to do!int body(){    char c;    while(1)    {        color = 0x01 + (running->pid % NPROC); // change the text color based on the process id!        printf("/n******************************/n");        printf("Currently Running Process #%d", running->pid);        printf("/nReady Queue: ");        printQueue(readyQueue);        printf("******************************/n");        printf("Input a command [s | q | f | r | ?]:");        c = getc();        printf("/n");        switch (c)        {            case 's': tswitch(); break;            case 'q': zombify(); break;            case 'f': kfork(); break;            case 'r': resurrect(); break;            case '?': help(); break;            default: break;        }    }}
开发者ID:vonderborch,项目名称:CS460,代码行数:26,


示例13: zombify

// turns the living into the undeadzombify(){    printf("/nProcess [%d] is now undead!", running->pid);    running->status = ZOMBIE;    tswitch();}
开发者ID:vonderborch,项目名称:CS460,代码行数:8,


示例14: ksleep

int ksleep(int event) {    running->event = event;    running->status = SLEEP;    tswitch();}
开发者ID:tymicruz,项目名称:CuatroSeisZero,代码行数:7,


示例15: kexit

int kexit(int event){    int i, hc = 0;    running->exitCode = event;    //run through each proc list to find any children    for(i = 0; i < NPROC; i++)    {        if(proc[i].ppid == running->pid) //child found        {            hc = 1;            if(running->pid == 1) {break;}            proc[i].ppid = 1; //change parent to proc1        }    }    if(running->pid == 1 && hc) //Can't let proc1 die    {        printf("Proc 1 still has children! Cannot die/n");        return -1;    }    running->status = ZOMBIE;    if(hc) {kwakeup(1);}    kwakeup(running->ppid);    tswitch();}
开发者ID:konorati,项目名称:cs460,代码行数:26,


示例16: grave

//kills a processint grave(){    int i,parent;    if (running->pid == 1)    {        for (i = 2;i<NPROC;i++)        {            if ((&proc[i])->status != FREE)                return;        }    }    if (running->pid != 1)    {        running->exitCode = 0;        for (i = 2;i<NPROC;i++)        {            if ((&proc[i])->ppid == running->pid)                (&proc[i])->ppid = 1;        }    }    running->status = ZOMBIE;    parent = running->ppid;    wakeup((int)(&proc[parent]));    printf("/n*****************************************/n");     printf("Task %d %s/n", running->pid,gasp[(running->pid) % 4]);    printf("*****************************************/n");    tswitch();   /* journey of no return */        }
开发者ID:B-Rich,项目名称:CptS460,代码行数:31,


示例17: sleep

//makes a proc sleep until woken by the specified eventint sleep(int event){    running->event = event;    running->status = SLEEP;    enqueue(&sleepList,running);    printf("sleeping on event: %d",event);    tswitch();}
开发者ID:B-Rich,项目名称:CptS460,代码行数:9,


示例18: ksleep

/********************************************************************Copyright 2010-2015 K.C. Wang, <[email
C++ tt函数代码示例
C++ tswap32函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。