📄 linktable.c
字号:
#include <malloc.h>
#include <string.h>
extern proc *hashproc[1031],*head[1031],*tail[1031],*p[1031];
void hash_init()
{
int i;
for(i=0;i<1030;i++)
{
if((hashproc[i]=(proc *)malloc(sizeof(proc)))==NULL)
{
printf("不能为%d分配内存空间!",i);
exit(0);
}
head[i] = p[i] = tail[i] = hashproc[i];
head[i]->pid = 0;
head[i]->pname[0] = '\0';
head[i]->cputime.prev_utime = head[i]->cputime.prev_stime = head[i]->cputime.curr_utime = head[i]->cputime.curr_stime = 0;
head[i]->rss = 0;
head[i]->seq = 0;
head[i]->next = NULL;
}
}
void hash_append(int cur,ulong pid,char *pname,ulong p_utime,ulong p_stime,ulong c_utime,ulong c_stime,ulong rss)
{
proc *newproc;
if((newproc=(proc *)malloc(sizeof(proc)))==NULL)
{
printf("不能为%d分配内存空间!",cur);
exit(0);
}
newproc->next = NULL;
tail[cur]->pid = pid;
strcpy(tail[cur]->pname,pname);
tail[cur]->cputime.prev_utime = p_utime;
tail[cur]->cputime.prev_stime = p_stime;
tail[cur]->cputime.curr_utime = c_utime;
tail[cur]->cputime.curr_stime = c_stime;
tail[cur]->rss = rss;
tail[cur]->seq++;
tail[cur]->next = newproc;
tail[cur] = tail[cur]->next;
}
proc *hash_search(int cur,ulong pid)
{
p[cur] = head[cur];
if( p[cur]->next == NULL) return NULL;
while( p[cur]->next != NULL )
{
if( p[cur]->pid == pid )
return p[cur];
else
p[cur] = p[cur]->next;
}
return NULL;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -