ALL > Computer and Education > courses > university courses > undergraduate courses > Operating System > classbefore2015 >
exercise 3.2&3.6_吴霏 Version 0
👤 Author: by wufei123 2015-09-29 21:06:59
3.2

answer:When a context switch occurs, the kernel saves the context of the old process in its PCB and loads the saved context of the new process scheduled to run.

 

3.6

answer:

#include<sys/types.h>
#include<stdio.h>
#include<unistd.h>
int main()
{
pid_t pid;
pid=fork();
if(pid<0){
fprintf(stderr,"Fork Failed");
exit(-1);
}
else if(pid==0){
int i,n;
scanf("%d",&n);
int a[n];
a[0]=0,a[1]=1;
for(i=0;i<n;i++){
a[i]=a[i-1]+a[i-2];
}

Please login to reply. Login

Reversion History

Loading...
No reversions found.