int get_CPU_number()
so that
a process can use it to get the number of the CPU that executes it.
//prototype of the new system call is as follows:
int get_CPU_number()
start_to_count_number_of_process_switches()
so that
a process can use it to begin to count the number of process switches the process makes. Besides, write another new system
call int stop_to_count_number_of_process_switches()
so that
a process can use it to stop to count the number of process switches the process makes and return the number of process
switches the process makes.
//prototype of the new system call is as follows:
void start_to_count_number_of_process_switches()
//prototype of the new system call is as follows:
int stop_to_count_number_of_process_switches()
#define ON 1;
#define OFF 0;
void main()
{ :
int a,b=0;
int switch=ON;
:
start_to_count_number_of_process_switches();
while(switch==ON)
{
:
sleep(0.01 second);
printf("[%d ]",b++);
:
if (this process has run 2 minutes)
switch=OFF;
:
:
}
a=stop_to_count_number_of_process_switches();
printf("\nDuring the past 2 minutes the process makes %d times process switches.\n",a);
}
#define ON 1;
#define OFF 0;
void main()
{ :
int a;
int switch=ON;
float b=0;
:
start_to_count_number_of_process_switches();
while(switch==ON)
{
:
b=b+1;
:
if (this process has run 2 minutes)
switch=OFF;
:
:
}
a=stop_to_count_number_of_process_switches();
printf("During the past 2 minutes the process makes %d times process switches.\n",a);
}
struct task_struct
, append it in the end of the struct. Do NOT insert it into
struct task_struct
.
gettimeofday()
to calculate the time a process used.
__switch_to()
.