|
@ -13,8 +13,14 @@ void history(char *cmdline) |
|
|
|
|
|
|
|
|
void print_history(char *argv) |
|
|
void print_history(char *argv) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
int i = num - atoi(argv); |
|
|
|
|
|
|
|
|
int i = 0; |
|
|
|
|
|
if(argv == NULL) |
|
|
|
|
|
{ |
|
|
|
|
|
for(; i<num; i++) |
|
|
|
|
|
puts(storage[i]); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
i = num - atoi(argv); |
|
|
if(i < 0) |
|
|
if(i < 0) |
|
|
{ |
|
|
{ |
|
|
i = 0; |
|
|
i = 0; |
|
@ -100,7 +106,6 @@ int Is_pipe(char **argv) |
|
|
void shell_direct(char **prog1, char **prog2) |
|
|
void shell_direct(char **prog1, char **prog2) |
|
|
{ |
|
|
{ |
|
|
int fd; |
|
|
int fd; |
|
|
if(prog1) |
|
|
|
|
|
if(fork() == 0) |
|
|
if(fork() == 0) |
|
|
{ |
|
|
{ |
|
|
if( (fd=open(prog2[0],O_RDWR | O_CREAT | O_NOCTTY | O_NDELAY))<0 ) |
|
|
if( (fd=open(prog2[0],O_RDWR | O_CREAT | O_NOCTTY | O_NDELAY))<0 ) |
|
@ -190,38 +195,4 @@ void mytop() |
|
|
|
|
|
|
|
|
return 1; |
|
|
return 1; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//tp 结构体 |
|
|
|
|
|
//包含了进程指针p和ticks,对应某个进程和滴答 |
|
|
|
|
|
struct tp { |
|
|
|
|
|
struct proc *p; |
|
|
|
|
|
u64_t ticks; |
|
|
|
|
|
}; |
|
|
|
|
|
//计算cputicks 用到当前进程和其他进程的,还涉及CPUTIME |
|
|
|
|
|
u64_t cputicks(struct proc *p1, struct proc *p2, int timemode) |
|
|
|
|
|
{ |
|
|
|
|
|
int i; |
|
|
|
|
|
u64_t t = 0; |
|
|
|
|
|
//计算每个进程proc的滴答,通过proc和当前进程prev_proc做比较,如果endpoint相等,则在循环中分别计算 |
|
|
|
|
|
for(i = 0; i < CPUTIMENAMES; i++) { |
|
|
|
|
|
if(!CPUTIME(timemode, i)) |
|
|
|
|
|
continue; |
|
|
|
|
|
if(p1->p_endpoint == p2->p_endpoint) { |
|
|
|
|
|
t = t + p2->p_cpucycles[i] - p1->p_cpucycles[i]; |
|
|
|
|
|
} else { |
|
|
|
|
|
t = t + p2->p_cpucycles[i]; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
// for(i = 0; i < CPUTIMENAMES; i++) { |
|
|
|
|
|
// if(!CPUTIME(timemode, i)) |
|
|
|
|
|
// continue; |
|
|
|
|
|
// if(proc->p_endpoint == prev_proc->p_endpoint) { |
|
|
|
|
|
// t = t + prev_proc->p_cpucycles[i] - proc->p_cpucycles[i]; |
|
|
|
|
|
// } else { |
|
|
|
|
|
// t = t + prev_proc->p_cpucycles[i]; |
|
|
|
|
|
// } |
|
|
|
|
|
// } |
|
|
|
|
|
return t; |
|
|
|
|
|
} |
|
|
|
|
|
*/ |
|
|
*/ |