操作系统实验报告

时间:2024.3.19

说明: 说明: hust1

 

    课程名称:       操作系统       

专业班级:计算机科学与技术xxxx班 

学    号:        xxxxxxx       

             姓    名:         xxxx          

指导老师:         xxxxx         

报告日期:     20xx年xx月xx日   

计算机科学与技术学院

课程设计概述

一、        实验目的

掌握Linux操作系统的使用方法;

了解Linux系统内核代码结构;

掌握实例操作系统的实现方法。

二、        实验要求

1、            掌握Linux操作系统的使用方法,包括键盘命令、系统调用;掌握在Linux下的编程环境。

l  编一个C程序,其内容为实现文件拷贝的功能;

l  编一个C程序,其内容为分窗口同时显示三个并发进程的运行结果。要求用到Linux下的图形库。

2、            掌握系统调用的实现过程,通过编译内核方法,增加一个新的系统调用。另编写一个应用程序,调用新增加的系统调用。

实现的功能是:文件拷贝;

3、            掌握增加设备驱动程序的方法。通过模块方法,增加一个新的设备驱动程序,其功能可以简单。

实现字符设备的驱动;

4、            了解和掌握/proc文件系统的特点和使用方法

l  了解/proc文件的特点和使用方法

l  监控系统状态,显示系统中若干部件使用情况

l  用图形界面实现系统监控状态。

5、            设计并实现一个模拟的文件系统(选作)

三、        设计说明

Linux系统版本12.10

新编译的内核版本3.6.11

              虚拟机VMware Fusion 3.0

              环境MAC OS X 10.68

实验一

一、           实验目的

    1. 编写一个C程序实现文件拷贝的功能

2. 编写一个C程序,其内容为分窗口同时显示三个并发进程的运行结果,要求用到Linux下的图形库。

二、           实验过程

1.  文件拷贝功能

要实现文件拷贝功能,主要用到的函数是open、write、read。

以前在windows下写C语言打开文件常用的fopen,此时不能用,因为fopen是ANSIC标准中的C语言库函数,在不同的系统中应该调用不同的内核api ;所以应该直接使用linux中的系统函数open。

主要用到的头文件:

Unistd.h        \\包含了许多Linux系统服务的函数原型,如:read、write

Fcntl.h          \\定义了很多宏和open,fcntl函数原型

Stdio.h       \\标准输入输出头文件

sys/types.h \\此头文件包含适当时应使用的多个基本派生类型

sys/stat.h \\包含了获取文件属性的一些函数

errno.h      \\用于调试错误代码是所需要的一些errno变量

string.h           \\包含了处理字符串的一些函数

设计思路:由命令行参数获取2个文件名,根据其文件名和路径分别打开该2个文件,设置一个循环,从源文件复制N个字节到目的文件,直到源文件指针到文件尾,最后关闭2个文件。

在可能出错的地方需要加上相应的报错代码和中断,并输出错误信息,以方便调试或是往后应用在第2小题中可能发生的错误。

理清楚设计思路后,根据需求写出相应的源代码见后页源程序代码scopy.c ;在Linux终端使用编译命令 gcc –o scopy scopy.c将程序编译并生产exe可执行文件。

然后手动创建一个测试文件test.txt ,在终端输入命令

./scopy test.txt target.txt

这样就能将源文件test.txt复制到目标文件target.txt

2.  分窗口显示并发进程的运行结果

 安装Linux下的GTK+:

首先要在Linux下载GTK+相关库文件并安装。

在终端输入sudo apt-get install gnome-core-devel ,然后根据提示操作,就会安装 libgtk2.0-dev libglib2.0-dev 等开发所需的相关库文件。

    $sudo apt-get install build-essential

$sudo apt-get install gnome-core-devel

$sudo apt-get install pkg-config

$sudo apt-get install libgtk2.0*

编译GTK+代码时需要包含的头文件是gtk/gtk.h,此外,还必须连接若干库;比如编译test.c时用以下命令。

gcc –o test test.c `pkg-config --cflags --libs gtk+-2.0`

在编写代码时需要用到的控件、窗口等视窗物件形态,用类GtkWidget定义其为指针类型。

        编写一个GTK+程序的基本步骤如下:

l  初始化Gtk

l  建立控件

l  登记消息与消息处理函数

l  执行消息循环函数gtk_main()

之后所设计的3个进程,基本上都是以这样的方式编写代码的,因为之前曾用过OpenGL,所以在这方面掌握的比较快。

              初始化主要使用的函数有

              gtk_init(&argc,&argv);                   //启动GTK

          gtk_window_new(GTK_WINDOW_TOPLEVEL);     //创建窗口

          gtk_window_set_title(GTK_WINDOW(window),"标题名"); //设置窗口标题名

          gtk_widget_set_usize(window, 200, 200);  //设置窗口大小

          gtk_widget_show(window);               //显示窗口

              建立控件的一般流程

              /*创建表格准备封装*/

              gtk_table_new (         //创建多少列

gint rows,                          //创建多少栏

gint columns,                     //用来决定表格如何来定大小

gint homogeneous);

              /*这个函数是将表格table,结合到窗口window里*/

              gtk_container_add(GTK_CONTAINER(window),table);

gtk_widget_show(table);  // 显示该表格

/*要把物件放进box中,可用以下函数*/

void gtk_table_attach_defaults (

GtkTable*table,          //参数("table")是选定某表格

GtkWidget*widget,          //("child")是想放进去的物件

gintleft_attach,           //以下参数是指定把物件放在哪里, 及用多少个boxes

gintright_attach,

ginttop_attach,

gintbottom_attach);

三、           实验结果

1.  文件拷贝功能

    2.  分窗口显示并发进程的运行结果

四、           源代码

1. 文件拷贝功能

#include <unistd.h>

#include <fcntl.h>

#include <stdio.h>

#include <sys/types.h>

#include <sys/stat.h>

#include <errno.h>

#include <string.h>

#define BUFFER_SIZE 1024   //缓冲区大小

int main(int argc,char **argv)

{

    int from_fd,to_fd;

    int bytes_read,bytes_write;

    char buffer[BUFFER_SIZE];   //设定一个缓冲区

    char *ptr;

     if(argc!=3)    //三个参数

     {

       fprintf(stderr,"Usage:%s fromfile tofile\n\a",argv[0]);

       return(-1);

      }

     /* 打开源文件 */

     if((from_fd=open(argv[1],O_RDONLY))==-1)

      {

        fprintf(stderr,"Open %s Error:%s\n",argv[1],strerror(errno));

        return(-1);

      }

     /* 创建目的文件 */

       if((to_fd=open(argv[2],O_WRONLY|O_CREAT,S_IRUSR|S_IWUSR))==-1)

       {

         fprintf(stderr,"Open %s Error:%s\n",argv[2],strerror(errno));

         return(-1);

       }

       while(bytes_read=read(from_fd,buffer,BUFFER_SIZE))

       {

          /* 出错*/

           if((bytes_read==-1)&&(errno!=EINTR)) break;

           else if(bytes_read>0)

            {

             ptr=buffer;

             while(bytes_write=write(to_fd,ptr,bytes_read))

             {

               /* 出错*/

                if((bytes_write==-1)&&(errno!=EINTR))break;

                  /* 写完了所有读的字节 */

                 else if(bytes_write==bytes_read) break;

                  /* 只写了一部分,继续写 */

                  else if(bytes_write>0)

                 {

                   ptr+=bytes_write;

                   bytes_read-=bytes_write;

                  }

               }

            /* 写的时候出错*/

             if(bytes_write==-1)break;

            }

         }

         close(from_fd);

         close(to_fd);

         return(1);

}

2.  分窗口显示并发进程的运行结果

#include <gtk/gtk.h>

#include <sys/types.h>

#include <unistd.h>

gint progress_timeout( gpointer pbar )

{

  gdouble new_val;

  char s[10];

  new_val = gtk_progress_bar_get_fraction (GTK_PROGRESS_BAR (pbar)) + 0.01;

  if (new_val > 1.0)

    new_val = 0.0;

  sprintf (s, "%.0f%%", new_val*100);

  gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (pbar), new_val);

  gtk_progress_bar_set_text (GTK_PROGRESS_BAR (pbar),s);

 

  return TRUE;

}

void destroy_progress( GtkWidget *widget)

{

    gtk_main_quit ();

}

void show(int argc,char *argv[],char *title )

{

    GtkWidget *window;

    GtkWidget *vbox;

    GtkWidget *pbar;

    GtkWidget *pbar2;

    GtkWidget *button;

    GtkWidget *label;

    int timer;

    char id_char[50];

    gtk_init (&argc, &argv);

    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

    gtk_window_set_resizable (GTK_WINDOW (window), TRUE);

    gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);

    g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (destroy_progress), NULL);

    gtk_window_set_title (GTK_WINDOW (window), title);

  

    gtk_container_set_border_width (GTK_CONTAINER (window), 0);

  

    vbox = gtk_vbox_new (FALSE, 10);

 

    gtk_container_set_border_width (GTK_CONTAINER (vbox), 10);

   

    gtk_container_add (GTK_CONTAINER (window), vbox);

   

    gtk_widget_show (vbox);

  

       sprintf (id_char, "本进程ID:%d", getpid ());

    label = gtk_label_new (id_char);

    gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);

 

    gtk_widget_show (label);

    sprintf (id_char, "父进程ID:%d", getppid ());

    label = gtk_label_new (id_char);

  

    gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);

    gtk_widget_show (label);

 

    pbar = gtk_progress_bar_new ();

    gtk_box_pack_start (GTK_BOX (vbox), pbar, FALSE, FALSE, 0);

    gtk_widget_show (pbar);

    timer = gtk_timeout_add (100, progress_timeout, pbar);

    button = gtk_button_new_with_label ("close");

    g_signal_connect_swapped (G_OBJECT (button), "clicked", G_CALLBACK (gtk_widget_destroy), window);

    gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);

    GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);

    gtk_widget_grab_default (button);

    gtk_widget_show (button);

    gtk_widget_show (window);

    gtk_main ();

}

int main(int argc, char *argv[])

{

    int pid = fork ();

    if (pid < 0)

                   printf ("error!\n");

    else if (pid == 0)

    {

                   int pid = fork ();            

                   if (pid < 0)

                       printf ("error!\n");

                   else if (pid == 0)

                       show (argc,argv,"process3");

                   else

                       show (argc,argv,"process2");    }

    else

                   show (argc,argv,"process1");  

}

实验二

一、    实验目的

    掌握系统调用的实现过程,通过编译内核方法,增加一个新的系统调用。另编写一个应用程序,调用新增加的系统调用。实现的功能是:文件拷贝。

二、    实验过程

  1. 下载并解压内核

到官方网站http://www.kernel.org/下载内核linux-3.6.11.tar.xz,将其放入/usr/src中,打开终端,使用下列命令对其解压:

#tar -xvf linux-3.6.11

该目录用来存放内核的源码。

  2. 修改内核

首先对系统调用模块添加一个自定义函数helloworld.c,即添加一个新的自定义函数到/arch/x86/kernel中。

在/include/linux/syscalls.h中添加如下代码,进行对系统调用模块的修改

asmlinkage int sys_helloworld(const char* s_file, const char* t_file);

   接着在arch/x86/syscalls/syscall_32.tbl添加

350 i386    helloworld          sys_helloworld

   在arch/x86/kernel/Makefile中添加

obj-y                    += helloworld.o

  3. 编译内核

依次在终端键入以下命令进行对内核的编译,此过程要持续2小时左右

sudo apt-get install fakeroot build-essential kernel-package libncurses5 libncurses5-dev

cp /boot/config-3.5.0-17-generic ./.config

make menuconfig

load .config

make-kpkg clean

fakeroot make-kpkg --initrd kernel_image kernel_headers

  4. 安装内核

编译完成内核咋终端输入以下命令对内核进行安装

sudo dpkg -i linux-image-3.6.11.Custom_i386.deb

sudo dpkg -i linux-headers-3.6.11.Custom_i386.deb

  5. 系统调用

使用如下命令实现对系统函数字符拷贝的调用

gcc -o testsys.c testsys

    ./testsys

三、    实验结果

四、    源代码

helloworld.c

#include <linux/kernel.h>

#include <linux/export.h>

#include <linux/mm.h>

#include <linux/utsname.h>

#include <linux/mman.h>

#include <linux/reboot.h>

#include <linux/prctl.h>

#include <linux/highuid.h>

#include <linux/fs.h>

#include <linux/kmod.h>

#include <linux/perf_event.h>

#include <linux/resource.h>

#include <linux/kexec.h>

#include <linux/workqueue.h>

#include <linux/capability.h>

#include <linux/device.h>

#include <linux/key.h>

#include <linux/times.h>

#include <linux/posix-timers.h>

#include <linux/security.h>

#include <linux/dcookies.h>

#include <linux/suspend.h>

#include <linux/tty.h>

#include <linux/signal.h>

#include <linux/cn_proc.h>

#include <linux/getcpu.h>

#include <linux/task_io_accounting_ops.h>

#include <linux/seccomp.h>

#include <linux/cpu.h>

#include <linux/personality.h>

#include <linux/ptrace.h>

#include <linux/fs_struct.h>

#include <linux/file.h>

#include <linux/mount.h>

#include <linux/gfp.h>

#include <linux/syscore_ops.h>

#include <linux/version.h>

#include <linux/ctype.h>

#include <linux/compat.h>

#include <linux/syscalls.h>

#include <linux/kprobes.h>

#include <linux/user_namespace.h>

#include <linux/kmsg_dump.h>

/* Move somewhere else to avoid recompiling? */

#include <generated/utsrelease.h>

#include <asm/uaccess.h>

#include <asm/io.h>

#include <asm/unistd.h>

#ifndef SET_UNALIGN_CTL

# define SET_UNALIGN_CTL(a,b)    (-EINVAL)

#endif

#ifndef GET_UNALIGN_CTL

# define GET_UNALIGN_CTL(a,b)   (-EINVAL)

#endif

#ifndef SET_FPEMU_CTL

# define SET_FPEMU_CTL(a,b)   (-EINVAL)

#endif

#ifndef GET_FPEMU_CTL

# define GET_FPEMU_CTL(a,b)  (-EINVAL)

#endif

#ifndef SET_FPEXC_CTL

# define SET_FPEXC_CTL(a,b)   (-EINVAL)

#endif

#ifndef GET_FPEXC_CTL

# define GET_FPEXC_CTL(a,b)   (-EINVAL)

#endif

#ifndef GET_ENDIAN

# define GET_ENDIAN(a,b)  (-EINVAL)

#endif

#ifndef SET_ENDIAN

# define SET_ENDIAN(a,b)   (-EINVAL)

#endif

#ifndef GET_TSC_CTL

# define GET_TSC_CTL(a)           (-EINVAL)

#endif

#ifndef SET_TSC_CTL

# define SET_TSC_CTL(a)            (-EINVAL)

#endif

asmlinkage int sys_helloworld(const char* s_file, const char* t_file)

{

    //printk("hello,world!\n");

    int bytes_read, bytes_write;

       //file id

    int from_fd, to_fd;             

    char buffer[100];   

    char *ptr; 

    mm_segment_t old_fs;  

    old_fs = get_fs(); 

    set_fs(KERNEL_DS);  

   

    if ((from_fd = sys_open(s_file,O_RDONLY,0)) == -1)   

            return -1;  

    if ((to_fd = sys_open(t_file,O_WRONLY|O_CREAT,S_IRUSR|S_IWUSR)) == -1)   

            return -2;  

           

    //read source file       

       while(bytes_read=sys_read(from_fd,buffer,1)) 

    { 

        if((bytes_read==-1)) break; 

        else if(bytes_read>0) 

        {  

            ptr=buffer;

                    //write to the target file

            while(bytes_write=sys_write(to_fd,ptr,bytes_read))

            { 

                if((bytes_write==-1))break; 

                else if(bytes_write==bytes_read) break; 

                else if(bytes_write>0) 

                { 

                    ptr+=bytes_write; 

                    bytes_read-=bytes_write; 

                } 

            }

            if(bytes_write==-1)break;

        } 

    }

    set_fs(old_fs); 

    return 0;

}   

testsys.c

#include <syscall.h>

#include <sys/types.h>

int main(void){

       syscall(350,"./test.txt","./target.txt");

       return 0;

}

实验三

一、    实验目的

    掌握增加设备驱动程序的方法。通过模块方法,增加一个新的设备驱动程序,其功能可以简单。实现字符设备的驱动。

二、    实验过程

    通过以下指令进行字符驱动程序的安装

sudo make

sudo insmod –f device.ko

添加设备

sudo mknod /dev/device c 147 0

实现功能

sudo ./sdevice

删除字符设备

sudo rmmod device

三、    实验结果

四、    源代码

device.c

#include <linux/module.h>

#include <linux/init.h>

#include <linux/fs.h>

#include <asm/uaccess.h>

MODULE_LICENSE("GPL");

#define MAJOR_NUM 147

static ssize_t d_read(struct file *, char *, size_t, loff_t*);

static ssize_t d_write(struct file *, const char *, size_t, loff_t*);

static ssize_t d_open(struct inode *,struct file *);

static ssize_t d_release(struct inode *,struct file *);

struct file_operations d_fops=

{

    .read=d_read,

    .write=d_write,

    .open=d_open,

    .release=d_release,

};

static char var[1024]="Device test:";

int counter=12;

static int __init device_init(void)

{

    int result;

    result = register_chrdev(MAJOR_NUM, "device", &d_fops);

    if(result)

    {

        printk("device register failure");

    }

    else

    {

    printk("device register success");

    }

    return result;

}

static void __exit device_exit(void)

{

    unregister_chrdev(MAJOR_NUM, "device");

    printk("unloading the device...");

}

static ssize_t d_read(struct file *filp, char *buf, size_t len, loff_t *off)

{

    if(copy_to_user(buf,var,1024*sizeof(char)))

    {

        return - EFAULT;

    }

    return sizeof(char);

}

static ssize_t d_write(struct file *filp,const char *buf,size_t len,loff_t *off)

{

    if(copy_from_user(var+counter,buf,len*sizeof(char)))

    {

        return - EFAULT;

    }

    counter+=len;

    return sizeof(char);

}

static ssize_t d_open(struct inode *inode,struct file *file)

{

    printk(KERN_INFO "open it!\n");

    return 0;

}

static ssize_t d_release(struct inode *inode,struct file *file)

{

    printk(KERN_INFO "close it\n");

    return 0; }

module_init(device_init);

module_exit(device_exit);

sdevice.c

#include <sys/types.h>

#include <sys/stat.h>

#include <stdio.h>

#include <fcntl.h>

#include <string.h>

main()

{

    int fd;

    char buffer[1024];

    int num;

    fd=open("/dev/device",O_RDWR,S_IRUSR|S_IWUSR);

    if(fd!=-1)

    {

        read(fd,buffer,1024*sizeof(char));

        printf("The device is %s\n",buffer);

        printf("Please input the characters written to device:\n");

        fgets(buffer,1024,stdin);

        num=strlen(buffer)-1;

        write(fd,buffer,num*sizeof(char));

        read(fd,buffer,1024*sizeof(char));

        printf("The device is %s\n",buffer);

        close(fd);

    }

    else

    {

        printf("Device open failure\n");

    }

}

实验四

一、    实验目的

了解和掌握/proc文件系统的特点和使用方法

了解/proc文件的特点和使用方法

监控系统状态,显示系统中若干部件使用情况

用图形界面实现系统监控状态。

二、    实验过程

通过在访问/kernel里的/proc文件获得meninfo等相关信息,并用gtk使其以图形方式显示,相关功能包括:

(1)获取并显示主机名

(2)获取并显示系统启动的时间 (未实现)

(3)显示系统到目前为止持续运行的时间 (未实现)

(4)显示系统的版本号

(5)显示cpu的型号和主频大小

(6)同过pid或者进程名查询一个进程,并显示该进程的详细信息,提供杀掉该进程的功能。

(7)显示系统所有进程的一些信息,包括pid,ppid,占用内存大小,优先级等等

(8)cpu使用率的图形化显示(2分钟内的历史纪录曲线) (未实现)

(9)内存和交换分区(swap)使用率的图形化显示(2分钟内的历史纪录曲线) (未实现)

(10)在状态栏显示当前时间 (未实现)

(11)在状态栏显示当前cpu使用率

(12)在状态栏显示当前内存使用情况

(13)用新线程运行一个其他程序 (未实现)

(14)关机功能(未实现)

三、    实验结果

四、    源代码

creatwindow.h

void end_program(GtkWidget *widget, gpointer data)

{

    gtk_main_quit();

}

void creatWindow(void)

{

    int i;

    window = g_object_new(GTK_TYPE_WINDOW,"title", "System Monitor","default_height", windowHeight,"default_width", windowWidth,NULL);

    gtk_container_border_width(GTK_CONTAINER(window),10);

    notebook = g_object_new(GTK_TYPE_NOTEBOOK, NULL);

    for (i=0;i<page_quantity;++i)

    {

        page_title[i]=g_object_new(GTK_TYPE_LABEL, "label", page_title_char[i], NULL);

        page_table[i] = gtk_table_new(gridQuanV,gridQuanH,FALSE);

    }

    g_signal_connect(window, "destroy", G_CALLBACK(end_program), NULL);

    gtk_container_add(GTK_CONTAINER(window),GTK_WIDGET(notebook));

    for (i=0;i<page_quantity;++i)

    {

        gtk_notebook_append_page(GTK_NOTEBOOK(notebook), GTK_WIDGET(page_table[i]), GTK_WIDGET(page_title[i]));

    }

}

generaldef.h

const int DebugMode=1;

const float RefershCycle=1;

char *markup1;

#define _SVID_SOURCE

#include <gtk/gtk.h>

#include <string.h>

#include <stdio.h>

#include <stdlib.h>

#include <dirent.h>

#include <sys/types.h>

#include <unistd.h>

/*==================================================*/

#define page_quantity 5

const int windowHeight=600;

const int windowWidth=900;

const int gridQuanV=100;

const int gridQuanH=100;

GtkWindow *window;

GtkNotebook *notebook;

GtkLabel *page_title[page_quantity];

char* page_title_char[page_quantity]={"System Brief","Resource Usage","Process Info","Module Info","Main Filesystem Info",};

GtkWidget *page_table[page_quantity];

#include "creatwindow.h"

/*==================================================*/

GtkImage *logo;

GtkLabel* hostNameLabel;

GtkLabel* hostNameText;

GtkLabel* linuxSystemLabel;

GtkLabel* kernelVersionText;

GtkLabel* hardwareBriefLabel;

GtkLabel* cpuInfoText;

GtkLabel* memInfoText;

GtkLabel* authorInfo;

GtkHSeparator* hSep1;

#include "page1.h"

/*==================================================*/

GtkFrame *page2Frame[page_quantity];

char* page2FrameName[page_quantity]={"System Overall Load","CPU Usage","Memory Usage","Network Activity",};

int* cpuStruct1;

int* cpuStruct2;

int countFlag=0;

float overallLoad[3];

GtkLabel* avgLoadLabel;

char overallLoadLabelBuffer[512];

float cpuUsage;

char cpuUsageText[512];

GtkProgress* cpuUsageProgressBar;

int memAll;

int memFree;

int swapAll;

int swapFree;

float memPercent;

float swapPercent;

GtkProgress* memProgressBar;

GtkProgress* swapProgressBar;

char memText[512];

char swapText[512];

int netReceive;

int netSend;

float receiveSpeed;

float sendSpeed;

GtkLabel* net1;

char bufNet[512];

#include "page2.h"

/*==================================================*/

int* processID=NULL;

int processNum=-1;

int R_process_num=0;

int S_process_num=0;

int D_process_num=0;

int Z_process_num=0;

int T_process_num=0;

struct PCB

{

    int PID;

    char* name;

    char* status;

    int pri;

    int UID;

    float memUseVmRSS;

    int cmdLine;

}* allProcessPCB=NULL;

GtkScrolledWindow *scrolled_window_p3;

GtkListStore *list_p3;

GtkTreeIter iter_p3;

GtkTreeView *view_p3;

GtkTreeViewColumn *pid_column,*name_column,*status_column,*pri_column,*uid_column,*mem_column,*cmd_column;

GtkCellRenderer *text_renderer_p3_1;

GtkCellRenderer *text_renderer_p3_2;

GtkCellRenderer *text_renderer_p3_3;

GtkCellRenderer *text_renderer_p3_4;

GtkCellRenderer *text_renderer_p3_5;

GtkCellRenderer *text_renderer_p3_6;

GtkCellRenderer *text_renderer_p3_7;

GtkFrame* page3Frame;

GtkLabel* page3Label;

char processOverallDataBuffer[512];

#include "page3.h"

/*==================================================*/

int moduleNum=0;

struct MODULE

{

    char name[512];

    int mem;

    char times[512];

}* allModule=NULL;

GtkScrolledWindow *scrolled_window_p4;

GtkListStore *list_p4;

GtkTreeIter iter_p4;

GtkTreeView *view_p4;

GtkTreeViewColumn *name_column_p4,*mem_column_p4,*times_column_p4;

GtkCellRenderer *text_renderer_p4_1;

GtkCellRenderer *text_renderer_p4_2;

GtkCellRenderer *text_renderer_p4_3;

GtkFrame* page4Frame;

GtkLabel* page4Label;

char moduleOverallDataBuffer[512];

#include "page4.h"

/*==================================================*/

int fsNum=0;

#define MAX_FILESYSTEM_NUM 100

struct FS

{

    char name[512];

    int ab;

    int ub;

    int fb;

    char usage[512];

    char point[512];

} allFs[MAX_FILESYSTEM_NUM];

GtkScrolledWindow *scrolled_window_p5;

GtkListStore *list_p5;

GtkTreeIter iter_p5;

GtkTreeView *view_p5;

GtkTreeViewColumn *name_column_p5,*ab_column_p5,*ub_column_p5,*fb_column_p5,*usage_column_p5,*point_column_p5;

GtkCellRenderer *text_renderer_p5_1;

GtkCellRenderer *text_renderer_p5_2;

GtkCellRenderer *text_renderer_p5_3;

GtkCellRenderer *text_renderer_p5_4;

GtkCellRenderer *text_renderer_p5_5;

GtkCellRenderer *text_renderer_p5_6;

GtkFrame* page5Frame;

GtkLabel* page5Label;

char fsOverallDataBuffer[512];

#include "page5.h"

/*==================================================*/

entry.c

#include "generaldef.h"

void updateAllPages()

{

    updatePage2();

    updatePage3();

    updatePage4();

    updatePage5();

}

int main(int argc, char *argv[])

{

    gtk_init(&argc, &argv);

    creatWindow();

    page1Generate();

    page2Generate();

    page3Generate();

    page4Generate();

    page5Generate();

    gtk_timeout_add((int)(RefershCycle*1000),updateAllPages,NULL);

    gtk_widget_show_all(GTK_WIDGET(window));

    gtk_main();

   

    return 0;

}

page1.h

void page1UpdateInfo(void)

{

}

int getInfo(char* file,char* buf,char* start,char* end)

{

    FILE *fp1=NULL;

    int i;

    char buf2[512];

    char* tempCharP=NULL;

    char* tempCharP2=NULL;

    char* tempCharP3=NULL;

    char* tempCharP4=NULL;

    for (i=0;i<512;++i)

    {

        buf[i]=0;

    }

   

    if ((start==NULL)&&(end==NULL))

    {

        fp1=fopen(file,"r");

        fgets(buf,512,fp1);

        fclose(fp1);

    }

    if (file&&start&&end)

    {

        fp1=fopen(file,"r");

        fgets(buf,512,fp1);

        while ((tempCharP=strstr(buf,start))==NULL)

        {

            tempCharP4=fgets(buf,512,fp1);

            if (!tempCharP4)

            {

                break;

            }

        }

        if (!tempCharP)

        {

            fclose(fp1);

            return 0;

        }

        tempCharP+=strlen(start);

        tempCharP2=strstr(buf,end);

        for (tempCharP3=tempCharP;tempCharP3<tempCharP2;++tempCharP3)

        {

            buf2[tempCharP3-tempCharP]=*tempCharP3;

        }

        buf2[tempCharP3-tempCharP]='\0';

        strcpy(buf,buf2);

        fclose(fp1);

    }

    if ((file==NULL)&&start&&end)

    {

        tempCharP=strstr(buf,start);

        if (!tempCharP)

        {

            return 0;

        }

        tempCharP+=strlen(start);

        tempCharP2=strstr(buf,end);

        for (tempCharP3=tempCharP;tempCharP3<tempCharP2;++tempCharP3)

        {

            buf2[tempCharP3-tempCharP]=*tempCharP3;

        }

        buf2[tempCharP3-tempCharP]='\0';

        strcpy(buf,buf2);

    }

    return 1;

}

void page1Generate(void)

{

    char buf[512];

    char buf2[512];

    //logo = g_object_new(GTK_TYPE_IMAGE, "file", "logo", NULL);

   

    hostNameLabel = gtk_label_new("Info not ready!");

    gtk_label_set_markup(GTK_LABEL(hostNameLabel),"<span font_desc=\"Times New Bold 20\">Hostname</span>");

    hostNameText = gtk_label_new("Info not ready!");

    getInfo("/proc/sys/kernel/hostname",buf,NULL,NULL);

    gtk_label_set_label(GTK_LABEL(hostNameText),buf);

   

    linuxSystemLabel = gtk_label_new("Info not ready!");

    gtk_label_set_markup(GTK_LABEL(linuxSystemLabel),"<span font_desc=\"Times New Bold 20\">Linux System</span>");

    kernelVersionText = gtk_label_new("Info not ready!");

    getInfo("/proc/sys/kernel/osrelease",buf,NULL,NULL);

    sprintf(buf2,"Kernel Version: ");

    strcat(buf2,buf);

    gtk_label_set_label(GTK_LABEL(kernelVersionText),buf2);

   

    hardwareBriefLabel = gtk_label_new("Info not ready!");

    gtk_label_set_markup(GTK_LABEL(hardwareBriefLabel),"<span font_desc=\"Times New Bold 20\">Hardware Brief Information</span>");

   

    cpuInfoText = gtk_label_new("Info not ready!");

    getInfo("/proc/cpuinfo",buf,"model name  : ","\n");

    sprintf(buf2,"CPU Model Name: ");

    strcat(buf2,buf);  

    gtk_label_set_label(GTK_LABEL(cpuInfoText),buf2);

   

    memInfoText = gtk_label_new("Info not ready!");

    getInfo("/proc/meminfo",buf,"MemTotal:      ","\n");

    sprintf(buf2,"Total Memory: ");

    strcat(buf2,buf);

    gtk_label_set_label(GTK_LABEL(memInfoText),buf2);

    hSep1=g_object_new(GTK_TYPE_HSEPARATOR, NULL);

   

    authorInfo = gtk_label_new("Info not ready!");

    gtk_label_set_justify(authorInfo,GTK_JUSTIFY_CENTER);

    gtk_label_set_markup(GTK_LABEL(authorInfo),"<span font_desc=\"Purisa Bold 23\" foreground=\"#000066\">Author: keithshaw</span>\n<span font_desc=\"URW Chancery L 15\" style=\"italic\" foreground=\"#00AAAA\">HUST CS1001 Mar.2013\n Compile succeed under ubuntu 12.10 with kernel 3.6.11</span>");

   /* gtk_table_attach(GTK_TABLE(page_table[0]),GTK_WIDGET(logo),

            0,gridQuanH/10,

            0,gridQuanV,

            GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL,

            0,0

            );*/

    gtk_table_attach(GTK_TABLE(page_table[0]),GTK_WIDGET(hostNameLabel),

            gridQuanH/10,gridQuanH,

            gridQuanV/100*10,gridQuanV/100*13,

            GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL,

            0,0

            );

    gtk_table_attach(GTK_TABLE(page_table[0]),GTK_WIDGET(hostNameText),

            gridQuanH/10,gridQuanH,

            gridQuanV/100*13,gridQuanV/100*14,

            GTK_FILL,GTK_FILL,

            0,0

            );

    gtk_table_attach(GTK_TABLE(page_table[0]),GTK_WIDGET(linuxSystemLabel),

            gridQuanH/10,gridQuanH,

            gridQuanV/100*17,gridQuanV/100*20,

            GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL,

            0,0

            );

    gtk_table_attach(GTK_TABLE(page_table[0]),GTK_WIDGET(kernelVersionText),

            gridQuanH/10,gridQuanH,

            gridQuanV/100*20,gridQuanV/100*21,

            GTK_FILL,GTK_FILL,

            0,0

            );

    gtk_table_attach(GTK_TABLE(page_table[0]),GTK_WIDGET(hardwareBriefLabel),

            gridQuanH/10,gridQuanH,

            gridQuanV/100*24,gridQuanV/100*27,

            GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL,

            0,0

            );

    gtk_table_attach(GTK_TABLE(page_table[0]),GTK_WIDGET(cpuInfoText),

            gridQuanH/10,gridQuanH,

            gridQuanV/100*27,gridQuanV/100*28,

            GTK_FILL,GTK_FILL,

            0,0

            );

    gtk_table_attach(GTK_TABLE(page_table[0]),GTK_WIDGET(memInfoText),

            gridQuanH/10,gridQuanH,

            gridQuanV/100*28,gridQuanV/100*29,

            GTK_FILL,GTK_FILL,

            0,0

            );

    gtk_table_attach(GTK_TABLE(page_table[0]),GTK_WIDGET(hSep1),

            gridQuanH/10,gridQuanH,

            gridQuanV/100*40,gridQuanV/100*41,

            GTK_FILL,GTK_FILL,

            0,0

            );

    gtk_table_attach(GTK_TABLE(page_table[0]),GTK_WIDGET(authorInfo),

            gridQuanH/10,gridQuanH,

            gridQuanV/100*55,gridQuanV/100*65,

            GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL,

            0,0

            );

    page1UpdateInfo();

}

page2.h

float getCPUUsage(void)

{

    char buf[512];

    char buf2[512];

    int i,j,len,start;

    long jiff0;

    long jiff1;

    float cpuUsage;

    if (!countFlag)

    {

        getInfo("/proc/stat",buf,"cpu  ","\n");

        countFlag=1;

        for (i=0;i<7;++i)

        {

            j=0;

            while (buf[j]!=' ')

            {

                buf2[j]=buf[j];

                j++;

            }

            buf2[j]='\0';

            cpuStruct2[i]=atol(buf2);

            len=strlen(buf);

            start=j+1;

            for(j=start;j<len;++j)

            {

                buf[j-start]=buf[j];

            }

        }

        return 0;

    }

    getInfo("/proc/stat",buf,"cpu  ","\n");

    for (i=0;i<7;++i)

    {

        j=0;

        while (buf[j]!=' ')

        {

            buf2[j]=buf[j];

            j++;

        }

        buf2[j]='\0';

        cpuStruct1[i]=cpuStruct2[i];

        cpuStruct2[i]=atol(buf2);

        len=strlen(buf);

        start=j+1;

        for(j=start;j<len;++j)

        {

            buf[j-start]=buf[j];

        }

    }

    jiff0=0;

    jiff1=0;

    for (i=0;i<7;++i)

    {

        jiff0+=cpuStruct1[i];

        jiff1+=cpuStruct2[i];

    }

    cpuUsage=100-(cpuStruct2[3]-cpuStruct1[3])*1.0/(jiff1-jiff0)*100;

    return cpuUsage;

}

void getOveralLoad(char* buf)

{

    int i,j,start,len;

    char buf2[512];

    getInfo("/proc/loadavg",buf,NULL,NULL);

    for (i=0;i<3;++i)

    {

        j=0;

        while (buf[j]!=' ')

        {

            buf2[j]=buf[j];

            j++;

        }

        buf2[j]='\0';

        overallLoad[i]=atof(buf2);

        len=strlen(buf);

        start=j+1;

        for(j=start;j<len;++j)

        {

            buf[j-start]=buf[j];

        }

    }

    sprintf(buf,"Last 1 minute: %.2f; Last 5 minute: %.2f; Last 15 minute: %.2f",overallLoad[0],overallLoad[1],overallLoad[2]);

}

void getMemInfo()

{

    char buf[512];

    getInfo("/proc/meminfo",buf,"MemTotal:      "," kB");

    memAll=atoi(buf)/1024;

    getInfo("/proc/meminfo",buf,"MemFree:       "," kB");

    memFree=atoi(buf)/1024;

    memPercent=1-memFree*1.0/memAll;

    getInfo("/proc/meminfo",buf,"SwapTotal:     "," kB");

    swapAll=atoi(buf)/1024;

    getInfo("/proc/meminfo",buf,"SwapFree:      "," kB");

    swapFree=atoi(buf)/1024;

    swapPercent=1-swapFree*1.0/swapAll;

}

float getSpecNumberFromBuf(char* buf,int numNo)

{

    float returnValue=-1;

    int i,j;

    int current=0;

    int start=-1;

    int end=-1;

    char buf2[512];

    for (i=0;(i<numNo)&&(current<strlen(buf));)

    {

        if ((buf[current]>='0')&&(buf[current]<='9')&&(buf[current-1]==':'||buf[current-1]==' '||buf[current-1]=='-'||buf[current-1]=='\t'||current==0)&&((buf[current+1]>='0')&&(buf[current+1]<='9')||buf[current+1]==' '||buf[current+1]=='\t'||buf[current+1]=='\n'))

        {

            start=current;

            if (buf[current-1]=='-')

            {

                start-=1;

            }

            while ((buf[current]!=' ')&&(buf[current]!='\t'))

            {

                current++;

            }

            end=current-1;

            for (j=start;j<=end;++j)

            {

                buf2[j-start]=buf[j];

            }

            buf2[j-start]='\0';

            returnValue=atof(buf2);

            i++;

            continue;

        }

        else

        {

            current++;

            continue;

        }

    }

    return returnValue;

}

float getSpecNumberFromFile(char* filename,int lineNo,int numNo)

{

    FILE *fp1=NULL;

    int i;

    char buf[512];

    float returnValue=0;

    fp1=fopen(filename,"r");

    i=0;

    while ((i++)<lineNo)

    {

        fgets(buf,512,fp1);

    }

    fclose(fp1);

    returnValue=getSpecNumberFromBuf(buf,numNo);

   

    return returnValue;

}

void getNetInfo()

{

    FILE *fp1=NULL;

    static int flag=0;

    char buf[512];

    float rawReceive=0;

    float rawSend=0;

    static int sendLast=0;

    static int sendNow=0;

    static int receiveNow=0;

    static int receiveLast=0;

    fp1=fopen("/proc/net/dev","r");

    while (fgets(buf,512,fp1)!=NULL)

    {

        if (strchr(buf,':'))

        {

            rawReceive=rawReceive+getSpecNumberFromBuf(buf,1);

            rawSend=rawSend+getSpecNumberFromBuf(buf,9);

        }

    }

    fclose(fp1);

    netReceive=(int)(rawReceive/1024);

    netSend=(int)(rawSend/1024);

    receiveNow=netReceive;

    sendNow=netSend;

    if (flag)

    {

        receiveSpeed=(receiveNow-receiveLast)*1.0/RefershCycle;

        sendSpeed=(sendNow-sendLast)*1.0/RefershCycle;

        receiveLast=receiveNow;

        sendLast=sendNow;

    }

    else

    {

        flag=1;

        receiveSpeed=0;

        sendSpeed=0;

    }

}

void updatePage2(void)

{

    getOveralLoad(overallLoadLabelBuffer);

    markup1 = g_markup_printf_escaped ("<span font_desc=\"URW Palladio Bold 15\">Last 1 minute:</span><span font_desc=\"URW Palladio Bold Italic 15\" foreground=\"#880000\"> %.2f</span><span font_desc=\"URW Palladio Bold 15\">; Last 5 minutes:</span><span font_desc=\"URW Palladio Bold Italic 15\" foreground=\"#880000\"> %.2f</span><span font_desc=\"URW Palladio Bold 15\">; Last 15 minutes:</span><span font_desc=\"URW Palladio Bold Italic 15\" foreground=\"#880000\"> %.2f</span>", overallLoad[0],overallLoad[1],overallLoad[2]);

    gtk_label_set_markup (GTK_LABEL (avgLoadLabel), markup1);

    g_free (markup1);

    cpuUsage=getCPUUsage();

    gtk_progress_set_percentage(GTK_PROGRESS(cpuUsageProgressBar),(double)(cpuUsage/100));

    sprintf(cpuUsageText,"CPU usage is %.2f%%",cpuUsage);

    g_object_set(cpuUsageProgressBar,"text", cpuUsageText,NULL);

    getMemInfo();

    gtk_progress_set_percentage(GTK_PROGRESS(memProgressBar),(double)(memPercent));

    sprintf(memText,"Total physical memory is %d MB, %.2f%% are currently used",memAll,memPercent*100);

    g_object_set(memProgressBar,"text", memText,NULL);

    gtk_progress_set_percentage(GTK_PROGRESS(swapProgressBar),(double)(swapPercent));

    sprintf(swapText,"Total swap memory is %d MB, %.2f%% are currently used",swapAll,swapPercent*100);

    g_object_set(swapProgressBar,"text", swapText,NULL);

    getNetInfo();

    markup1 = g_markup_printf_escaped ("<span font_desc=\"URW Palladio Bold 15\">Network totally receive </span><span font_desc=\"URW Palladio Bold Italic 15\" foreground=\"#880000\">%dKB</span><span font_desc=\"URW Palladio Bold 15\"> data till now, totally send </span><span font_desc=\"URW Palladio Bold Italic 15\" foreground=\"#880000\">%dKB</span><span font_desc=\"URW Palladio Bold 15\"> data till now\n\nNetwork receive speed is </span><span font_desc=\"URW Palladio Bold Italic 15\" foreground=\"#880000\">%.2fKB/s</span><span font_desc=\"URW Palladio Bold 15\">, send speed is </span><span font_desc=\"URW Palladio Bold Italic 15\" foreground=\"#880000\">%.2fKB/s</span>",netReceive,netSend,receiveSpeed,sendSpeed);

    gtk_label_set_markup (GTK_LABEL (net1), markup1);

    g_free (markup1);

}

void page2Generate(void)

{

    int i;

    cpuStruct1=malloc(7*sizeof(int));

    cpuStruct2=malloc(7*sizeof(int));

    for (i=0;i<4;++i)

    {

        page2Frame[i]=g_object_new(GTK_TYPE_FRAME, "label", page2FrameName[i], NULL);

        gtk_table_attach(GTK_TABLE(page_table[1]),GTK_WIDGET(page2Frame[i]),

            0,gridQuanH,

            i*(gridQuanV/4),(i+1)*(gridQuanV/4),

            GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL,

            10,7

            );

    }

    getOveralLoad(overallLoadLabelBuffer);

    avgLoadLabel=gtk_label_new(overallLoadLabelBuffer);

    markup1 = g_markup_printf_escaped ("<span font_desc=\"URW Palladio Bold 15\">Last 1 minute:</span><span font_desc=\"URW Palladio Bold Italic 15\" foreground=\"#880000\"> %.2f</span><span font_desc=\"URW Palladio Bold 15\">; Last 5 minutes:</span><span font_desc=\"URW Palladio Bold Italic 15\" foreground=\"#880000\"> %.2f</span><span font_desc=\"URW Palladio Bold 15\">; Last 15 minutes:</span><span font_desc=\"URW Palladio Bold Italic 15\" foreground=\"#880000\"> %.2f</span>", overallLoad[0],overallLoad[1],overallLoad[2]);

    gtk_label_set_markup (GTK_LABEL (avgLoadLabel), markup1);

    g_free (markup1);

    gtk_table_attach(GTK_TABLE(page_table[1]),GTK_WIDGET(avgLoadLabel),

            0,gridQuanH,

            0,gridQuanV/4,

            GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL,

            10,20

            );

    cpuUsageProgressBar = g_object_new(GTK_TYPE_PROGRESS_BAR, NULL);

    cpuUsage=getCPUUsage();

    gtk_progress_set_percentage(GTK_PROGRESS(cpuUsageProgressBar),(double)(cpuUsage/100));

    sprintf(cpuUsageText,"CPU usage is %.2f%%",cpuUsage);

    g_object_set(cpuUsageProgressBar,"text", cpuUsageText,NULL);

    gtk_table_attach(GTK_TABLE(page_table[1]),GTK_WIDGET(cpuUsageProgressBar),

            0,gridQuanH,

            gridQuanV/4,gridQuanV/2,

            GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL,

            50,50

            );

    getMemInfo();

    memProgressBar = g_object_new(GTK_TYPE_PROGRESS_BAR, NULL);

    gtk_progress_set_percentage(GTK_PROGRESS(memProgressBar),(double)(memPercent));

    sprintf(memText,"Total physical memory is %d MB, %.2f%% are currently used",memAll,memPercent*100);

    g_object_set(memProgressBar,"text", memText,NULL);

    gtk_table_attach(GTK_TABLE(page_table[1]),GTK_WIDGET(memProgressBar),

            0,gridQuanH,

            gridQuanV/2+10,gridQuanV/2+gridQuanV/8,

            GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL,

            50,8

            );

    swapProgressBar = g_object_new(GTK_TYPE_PROGRESS_BAR, NULL);

    gtk_progress_set_percentage(GTK_PROGRESS(swapProgressBar),(double)(swapPercent));

    sprintf(swapText,"Total swap memory is %d MB, %.2f%% are currently used",swapAll,swapPercent*100);

    g_object_set(swapProgressBar,"text", swapText,NULL);

    gtk_table_attach(GTK_TABLE(page_table[1]),GTK_WIDGET(swapProgressBar),

            0,gridQuanH,

            gridQuanV/2+gridQuanV/8,gridQuanV/4*3-10,

            GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL,

            50,8

            );

    getNetInfo();

    sprintf(bufNet,"Network totally receive %dKB data till now, totally send %dKB data till now.\n\nNetwork receive speed is %.2fKB/s, send speed %.2fKB/s.",netReceive,netSend,receiveSpeed,sendSpeed);

    net1 = gtk_label_new(bufNet);

    gtk_label_set_justify(GTK_LABEL(net1),GTK_JUSTIFY_CENTER);

    markup1 = g_markup_printf_escaped ("<span font_desc=\"URW Palladio Bold 15\">Network totally receive </span><span font_desc=\"URW Palladio Bold Italic 15\" foreground=\"#880000\">%dKB</span><span font_desc=\"URW Palladio Bold 15\"> data till now, totally send </span><span font_desc=\"URW Palladio Bold Italic 15\" foreground=\"#880000\">%dKB</span><span font_desc=\"URW Palladio Bold 15\"> data till now\n\nNetwork receive speed is </span><span font_desc=\"URW Palladio Bold Italic 15\" foreground=\"#880000\">%.2fKB/s</span><span font_desc=\"URW Palladio Bold 15\">, send speed is </span><span font_desc=\"URW Palladio Bold Italic 15\" foreground=\"#880000\">%.2fKB/s</span>",netReceive,netSend,receiveSpeed,sendSpeed);

    gtk_label_set_markup (GTK_LABEL (net1), markup1);

    g_free (markup1);

    gtk_table_attach(GTK_TABLE(page_table[1]),GTK_WIDGET(net1),

            0,gridQuanH,

            gridQuanV/4*3,gridQuanV,

            GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL,

            50,20

            );

}

page3.h

void getProcessID()

{

    struct dirent **namelist;

    int n=0;

    n = scandir("/proc", &namelist, 0, alphasort);

    if (processID)

    {

        free(processID);

    }

    processID=malloc(n*sizeof(int));

    processNum=0;

    while (n--)

    {

        if (((namelist[n]->d_name)[0]>='0')&&((namelist[n]->d_name)[0]<='9'))

        {

            processID[processNum++]=atoi(namelist[n]->d_name);

        }

        free(namelist[n]);

    }

    free(namelist);

}

void getUID(char* currentFilename,char* buf)

{

    FILE* fp1;

    int i;

    int uid;

    fp1=fopen(currentFilename,"r");

    for (i=0;i<7;++i)

    {

        fgets(buf,512,fp1);

    }

    uid=(int)(getSpecNumberFromBuf(buf,1));

    sprintf(buf,"%d",uid);

    fclose(fp1);

}

void buildAllPCB(void)

{

    static char currentFilename[512];

    int i;

    static char buf[512];

    R_process_num=0;

    S_process_num=0;

    D_process_num=0;

    Z_process_num=0;

    T_process_num=0;

    getProcessID();

   

    if (allProcessPCB)

    {

        free(allProcessPCB);

    }

    allProcessPCB=malloc(processNum*sizeof(struct PCB));

    for (i=0;i<processNum;++i)

    {

        sprintf(currentFilename,"/proc/%d/status",processID[i]);

       

        if (!getInfo(currentFilename,buf,"Pid:       ","\n"))

        {

            allProcessPCB[i].PID=-1;

        }

        else

        {

            allProcessPCB[i].PID=atoi(buf);

        }

        if (!getInfo(currentFilename,buf,"Name:   ","\n"))

        {

            allProcessPCB[i].name=NULL;

        }

        else

        {

            allProcessPCB[i].name=malloc(512*sizeof(char));

            strcpy(allProcessPCB[i].name,buf);

        }

        if (!getInfo(currentFilename,buf,"State:    ","\n"))

        {

            allProcessPCB[i].status=NULL;

        }

        else

        {

            allProcessPCB[i].status=malloc(512*sizeof(char));

            strcpy(allProcessPCB[i].status,buf);

            switch (buf[0])

            {

                case 'R':R_process_num++;break;

                case 'S':S_process_num++;break;

                case 'D':D_process_num++;break;

                case 'Z':Z_process_num++;break;

                case 'T':T_process_num++;break;

            };

        }

        getUID(currentFilename,buf);

        if (!buf)

        {

            allProcessPCB[i].UID=-1;

        }

        else

        {

            allProcessPCB[i].UID=atoi(buf);

        }

        if (!getInfo(currentFilename,buf,"VmRSS:          "," kB"))

        {

            allProcessPCB[i].memUseVmRSS=-1;

        }

        else

        {

            allProcessPCB[i].memUseVmRSS=atof(buf);

        }

        sprintf(currentFilename,"/proc/%d/cmdline",processID[i]);

        if (!getInfo(currentFilename,buf,NULL,NULL))

        {

            allProcessPCB[i].cmdLine=NULL;

        }

        else

        {

            allProcessPCB[i].cmdLine=malloc(512*sizeof(char));

            strcpy(allProcessPCB[i].cmdLine,buf);

        }

        sprintf(currentFilename,"/proc/%d/stat",processID[i]);

        if (!getInfo(currentFilename,buf,NULL,NULL))

        {

            allProcessPCB[i].pri=-10000;

        }

        else

        {

            allProcessPCB[i].pri=(int)(getSpecNumberFromBuf(buf,16));

        }

    }

}

void updatePage3()

{

    int i;

    static char buf[7][512];

    static int flag=0;

   

    buildAllPCB();

    if (flag)

    {

        markup1 = g_markup_printf_escaped ("<span font_desc=\"URW Gothic L Bold 17\">In total, %d process exists.</span><span font_desc=\"URW Gothic L 12\">\n--------------------------------------------------------------------------------\n%d process in runnable(R) state\n%d process in sleeping(S) state\n%d process in uninterruptible sleep(D) state\n%d process in zombile(Z) state\n%d process in traced or stopped(T) state</span>"

            ,processNum,R_process_num,S_process_num,D_process_num,Z_process_num,T_process_num);

        gtk_label_set_markup (GTK_LABEL (page3Label), markup1);

        g_free (markup1);

    }

    flag=1;

   

    gtk_list_store_clear(GTK_LIST_STORE(list_p3));

    /* put data into the list */

    for (i = 0; i < processNum; i++)

    {

        if (allProcessPCB[i].PID==-1)

        {

            sprintf(buf[0],"N/A   ");

        }

        else

        {

            sprintf(buf[0],"%d   ",allProcessPCB[i].PID);

        }

        if (allProcessPCB[i].name==NULL)

        {

            sprintf(buf[1],"N/A   ");

        }

        else

        {

            sprintf(buf[1],"%s   ",allProcessPCB[i].name);

        }

        if (allProcessPCB[i].status==NULL)

        {

            sprintf(buf[2],"N/A   ");

        }

        else

        {

            sprintf(buf[2],"%s   ",allProcessPCB[i].status);

        }

        if (allProcessPCB[i].UID==-1)

        {

            sprintf(buf[4],"N/A   ");

        }

        else

        {

            sprintf(buf[4],"%d   ",allProcessPCB[i].UID);

        }

        if (allProcessPCB[i].memUseVmRSS==-1)

        {

            sprintf(buf[5],"N/A   ");

        }

        else

        {

            sprintf(buf[5],"%.1f   ",allProcessPCB[i].memUseVmRSS);

        }

        if (allProcessPCB[i].cmdLine==NULL)

        {

            sprintf(buf[6],"N/A   ");

        }

        else

        {

            sprintf(buf[6],"%s   ",allProcessPCB[i].cmdLine);

        }

        if (allProcessPCB[i].pri==-10000)

        {

            sprintf(buf[3],"N/A   ");

        }

        else

        {

            sprintf(buf[3],"%d   ",allProcessPCB[i].pri);

        }

        gtk_list_store_append(list_p3, &iter_p3);

        gtk_list_store_set(list_p3, &iter_p3,

                0,buf[0],

                1,buf[1],

                2,buf[2],

                3,buf[3],

                4,buf[4],

                5,buf[5],

                6,buf[6],

                -1);

    }

}

page3Generate()

{

    /* create a 7?column list */

    list_p3 = gtk_list_store_new(7,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING);

    updatePage3();

    /* create tree view for the list */

    view_p3 = g_object_new(GTK_TYPE_TREE_VIEW,

            "model", list_p3,

            "reorderable", TRUE,

            NULL);

    gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(view_p3),TRUE);

    /* create and initialize text renderer for cells */

    text_renderer_p3_1 = gtk_cell_renderer_text_new();

    g_object_set(text_renderer_p3_1, "font", "URW Gothic L","weight",1500,NULL);

    text_renderer_p3_2 = gtk_cell_renderer_text_new();

    g_object_set(text_renderer_p3_2, "font", "URW Gothic L",NULL);

    text_renderer_p3_3 = gtk_cell_renderer_text_new();

    g_object_set(text_renderer_p3_3, "font", "URW Gothic L",NULL);

    text_renderer_p3_4 = gtk_cell_renderer_text_new();

    g_object_set(text_renderer_p3_4, "font", "URW Gothic L",NULL);

    text_renderer_p3_5 = gtk_cell_renderer_text_new();

    g_object_set(text_renderer_p3_5, "font", "URW Gothic L",NULL);

    text_renderer_p3_6 = gtk_cell_renderer_text_new();

    g_object_set(text_renderer_p3_6, "font", "URW Gothic L",NULL);

    text_renderer_p3_7 = gtk_cell_renderer_text_new();

    g_object_set(text_renderer_p3_7, "font", "Purisa",NULL);

    /* create column views */

    pid_column = gtk_tree_view_column_new_with_attributes("PID",text_renderer_p3_1,"text", 0,NULL);

    g_object_set(pid_column,

            "resizable", TRUE,

            "clickable", FALSE,

            "reorderable", TRUE,

            NULL);

    name_column = gtk_tree_view_column_new_with_attributes("Name",text_renderer_p3_2,"text", 1,NULL);

    g_object_set(name_column,

            "resizable", TRUE,

            "clickable", FALSE,

            "reorderable", TRUE,

            NULL);

    status_column = gtk_tree_view_column_new_with_attributes("Status",text_renderer_p3_3,"text", 2,NULL);

    g_object_set(status_column,

            "resizable", TRUE,

            "clickable", FALSE,

            "reorderable", TRUE,

            NULL);

    pri_column = gtk_tree_view_column_new_with_attributes("Priority",text_renderer_p3_4,"text", 3,NULL);

    g_object_set(pri_column,

            "resizable", TRUE,

            "clickable", FALSE,

            "reorderable", TRUE,

            NULL);

    uid_column = gtk_tree_view_column_new_with_attributes("UID",text_renderer_p3_5,"text", 4,NULL);

    g_object_set(uid_column,

            "resizable", TRUE,

            "clickable", FALSE,

            "reorderable", TRUE,

            NULL);

    mem_column = gtk_tree_view_column_new_with_attributes("Physical Memory Usage\nin KB (VmRSS)",text_renderer_p3_6,"text", 5,NULL);

    g_object_set(mem_column,

            "resizable", TRUE,

            "clickable", FALSE,

            "reorderable", TRUE,

            NULL);

    cmd_column = gtk_tree_view_column_new_with_attributes("Command Line",text_renderer_p3_7,"text", 6,NULL);

    g_object_set(cmd_column,

            "resizable", TRUE,

            "clickable", FALSE,

            "reorderable", TRUE,

            NULL);

    /* insert columns into the view */

    gtk_tree_view_append_column(view_p3,pid_column);

    gtk_tree_view_append_column(view_p3,name_column);

    gtk_tree_view_append_column(view_p3,status_column);

    gtk_tree_view_append_column(view_p3,pri_column);

    gtk_tree_view_append_column(view_p3,uid_column);

    gtk_tree_view_append_column(view_p3,mem_column);

    gtk_tree_view_append_column(view_p3,cmd_column);

   

    /* put everything into a scrolled window */

    scrolled_window_p3 = g_object_new(GTK_TYPE_SCROLLED_WINDOW, NULL);

    gtk_container_add(GTK_CONTAINER(scrolled_window_p3), GTK_WIDGET(view_p3));

    gtk_table_attach(GTK_TABLE(page_table[2]),GTK_WIDGET(scrolled_window_p3),

            0,gridQuanH,

            0,gridQuanV/4*3,

            GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL,

            10,10

            );

    page3Frame=g_object_new(GTK_TYPE_FRAME, "label", "Process Overall Views", NULL);

    gtk_table_attach(GTK_TABLE(page_table[2]),GTK_WIDGET(page3Frame),

            0,gridQuanH,

            gridQuanV/4.0*3.7,gridQuanV,

            GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL,

            10,5

            );

    sprintf(processOverallDataBuffer,"In total, %d process exists.\n====================\n%d process in runnable(R) state\n%d process in sleeping(S) state\n%d process in uninterruptible sleep(D) state\n%d process in zombile(Z) state\n%d process in traced or stopped(T) state\n===================="

            ,processNum,R_process_num,S_process_num,D_process_num,Z_process_num,T_process_num);

    page3Label=gtk_label_new(processOverallDataBuffer);

    gtk_label_set_justify(GTK_LABEL(page3Label),GTK_JUSTIFY_CENTER);

    markup1 = g_markup_printf_escaped ("<span font_desc=\"URW Palladio Bold 10\">In total, %d process exists.\n====================\n%d process in runnable(R) state\n%d process in sleeping(S) state\n%d process in uninterruptible sleep(D) state\n%d process in zombile(Z) state\n%d process in traced or stopped(T) state\n====================</span>"

            ,processNum,R_process_num,S_process_num,D_process_num,Z_process_num,T_process_num);

    gtk_label_set_markup (GTK_LABEL (page3Label), markup1);

    g_free (markup1);

    gtk_table_attach(GTK_TABLE(page_table[2]),GTK_WIDGET(page3Label),

            0,gridQuanH,

            gridQuanV/4.0*3.7,gridQuanV,

            GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL,

            10,0

            );

}

page4.h

void getModuleInfo()

{

    FILE* fp1;

    char buf3[512];

    int i,j;

    moduleNum=0;

    fp1=fopen("/proc/modules","r");

    while(fgets(buf3,512,fp1))

    {

        moduleNum++;

    }

    fclose(fp1);

    if (allModule)

    {

        free(allModule);

    }

    allModule=malloc(moduleNum*sizeof(struct MODULE));

    fp1=fopen("/proc/modules","r");

    for (i=0;i<moduleNum;++i)

    {

        fgets(buf3,512,fp1);

        j=0;

        while(buf3[j]!=' ')

        {

            (allModule[i].name)[j]=buf3[j];

            j++;

        }

        (allModule[i].name)[j]='\0';

        allModule[i].mem=(int)(getSpecNumberFromBuf(buf3,1));

        j=(int)(getSpecNumberFromBuf(buf3,2));

        sprintf(allModule[i].times,"%d",j);

    }

    fclose(fp1);

}

void updatePage4()

{

    int i;

    static char buf4[3][512];

    static int flag2=0;

    getModuleInfo();

    if (flag2)

    {

        markup1 = g_markup_printf_escaped ("<span font_desc=\"URW Gothic L Bold 20\">In total, %d modules installed into the kernel.</span>",moduleNum);

        gtk_label_set_markup (GTK_LABEL (page4Label), markup1);

        g_free (markup1);

    }

    flag2=1;

    gtk_list_store_clear(GTK_LIST_STORE(list_p4));

    /* put data into the list */

    for (i = 0; i < moduleNum; i++)

    {

        if (allModule[i].name==NULL)

        {

            sprintf(buf4[0],"N/A   ");

        }

        else

        {

            sprintf(buf4[0],"%s   ",allModule[i].name);

        }

        if (allModule[i].mem==-1)

        {

            sprintf(buf4[1],"N/A   ");

        }

        else

        {

            sprintf(buf4[1],"%d   ",allModule[i].mem);

        }

        if (allModule[i].times==NULL)

        {

            sprintf(buf4[2],"N/A   ");

        }

        else

        {

            sprintf(buf4[2],"%s   ",allModule[i].times);

        }

       

        gtk_list_store_append(list_p4, &iter_p4);

        gtk_list_store_set(list_p4, &iter_p4,

                0,buf4[0],

                1,buf4[1],

                2,buf4[2],

                -1);

    }

}

page4Generate()

{

    /* create a 3?column list */

    list_p4 = gtk_list_store_new(3,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING);

    updatePage4();

    /* create tree view for the list */

    view_p4 = g_object_new(GTK_TYPE_TREE_VIEW,

            "model", list_p4,

            "reorderable", TRUE,

            NULL);

    gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(view_p4),TRUE);

    /* create and initialize text renderer for cells */

    text_renderer_p4_1 = gtk_cell_renderer_text_new();

    g_object_set(text_renderer_p4_1, "font", "URW Gothic L","weight",1500,NULL);

    text_renderer_p4_2 = gtk_cell_renderer_text_new();

    g_object_set(text_renderer_p4_2, "font", "URW Gothic L",NULL);

    text_renderer_p4_3 = gtk_cell_renderer_text_new();

    g_object_set(text_renderer_p4_3, "font", "URW Gothic L",NULL);

    /* create column views */

    name_column_p4 = gtk_tree_view_column_new_with_attributes("Name",text_renderer_p4_1,"text", 0,NULL);

    g_object_set(name_column_p4,

            "resizable", TRUE,

            "clickable", FALSE,

            "reorderable", TRUE,

            NULL);

    mem_column_p4 = gtk_tree_view_column_new_with_attributes("Size",text_renderer_p4_2,"text", 1,NULL);

    g_object_set(mem_column_p4,

            "resizable", TRUE,

            "clickable", FALSE,

            "reorderable", TRUE,

            NULL);

    times_column_p4 = gtk_tree_view_column_new_with_attributes("Used times by other modules",text_renderer_p4_3,"text", 2,NULL);

    g_object_set(times_column_p4,

            "resizable", TRUE,

            "clickable", FALSE,

            "reorderable", TRUE,

            NULL);

    /* insert columns into the view */

    gtk_tree_view_append_column(view_p4,name_column_p4);

    gtk_tree_view_append_column(view_p4,mem_column_p4);

    gtk_tree_view_append_column(view_p4,times_column_p4);

    /* put everything into a scrolled window */

    scrolled_window_p4 = g_object_new(GTK_TYPE_SCROLLED_WINDOW, NULL);

    gtk_container_add(GTK_CONTAINER(scrolled_window_p4), GTK_WIDGET(view_p4));

    gtk_table_attach(GTK_TABLE(page_table[3]),GTK_WIDGET(scrolled_window_p4),

            0,gridQuanH,

            0,gridQuanV/10*9,

            GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL,

            10,10

            );

    page4Frame=g_object_new(GTK_TYPE_FRAME, "label", "Modules Overall View", NULL);

    gtk_table_attach(GTK_TABLE(page_table[3]),GTK_WIDGET(page4Frame),

            0,gridQuanH,

            gridQuanV/10*9,gridQuanV,

            GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL,

            10,5

            );

    sprintf(moduleOverallDataBuffer,"In total, %d modules loads into kernel",moduleNum);

    page4Label=gtk_label_new(moduleOverallDataBuffer);

    gtk_label_set_justify(GTK_LABEL(page4Label),GTK_JUSTIFY_CENTER);

    markup1 = g_markup_printf_escaped ("<span font_desc=\"URW Palladio Bold 17\">In total, %d modules loads into kernel</span>",moduleNum);

    gtk_label_set_markup (GTK_LABEL (page4Label), markup1);

    g_free (markup1);

    gtk_table_attach(GTK_TABLE(page_table[3]),GTK_WIDGET(page4Label),

            0,gridQuanH,

            gridQuanV/10*9,gridQuanV,

            GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL,

            10,0

            );

}

page5.h

void prepareData()

{

    FILE   *stream;

    FILE   *wstream;

    char   buf[1024];

    memset( buf, '\0', sizeof(buf) );

    stream = popen( "df", "r" );

    wstream = fopen( "tempfile", "w");

    fread( buf, sizeof(char), sizeof(buf),  stream);

    fwrite( buf, 1, sizeof(buf), wstream );

    pclose( stream );

    fclose( wstream );

}

void getFsInfo()

{

    FILE* fp1;

    char buf7[6][512];

    prepareData();

    fp1=fopen("tempfile","r");

    fsNum=0;

    fgets(buf7[0],512,fp1);

    while(1)

    {

        if(fscanf(fp1,"%s",buf7[0])==EOF)

        {

            break;

        }

        if(fscanf(fp1,"%s",buf7[1])==EOF)

        {

            break;

        }

        if(fscanf(fp1,"%s",buf7[2])==EOF)

        {

            break;

        }

        if(fscanf(fp1,"%s",buf7[3])==EOF)

        {

            break;

        }

        if(fscanf(fp1,"%s",buf7[4])==EOF)

        {

            break;

        }

        if(fscanf(fp1,"%s",buf7[5])==EOF)

        {

            break;

        }

        fsNum++;

        strcpy(allFs[fsNum-1].name,buf7[0]);

        allFs[fsNum-1].ab=(int)(atof(buf7[1])/1024);

        allFs[fsNum-1].ub=(int)(atof(buf7[2])/1024);

        allFs[fsNum-1].fb=(int)(atof(buf7[3])/1024);

        strcpy(allFs[fsNum-1].usage,buf7[4]);

        strcpy(allFs[fsNum-1].point,buf7[5]);

    }

    fclose(fp1);

}

void updatePage5()

{

    int i;

    static char buf6[6][512];

    static int flag3=0;

    getFsInfo();

    if (flag3)

    {

        markup1 = g_markup_printf_escaped ("<span font_desc=\"URW Gothic L Bold 20\">In total, %d main filesystem found</span>",fsNum);

        gtk_label_set_markup (GTK_LABEL (page5Label), markup1);

        g_free (markup1);

    }

    flag3=1;

    gtk_list_store_clear(GTK_LIST_STORE(list_p5));

    /* put data into the list */

    for (i = 0; i < fsNum; i++)

    {

        if (allFs[i].name==NULL)

        {

            sprintf(buf6[0],"N/A   ");

        }

        else

        {

            sprintf(buf6[0],"%s   ",allFs[i].name);

        }

        if (allFs[i].ab==-1)

        {

            sprintf(buf6[1],"N/A   ");

        }

        else

        {

            sprintf(buf6[1],"%d   ",allFs[i].ab);

        }

        if (allFs[i].ub==-1)

        {

            sprintf(buf6[2],"N/A   ");

        }

        else

        {

            sprintf(buf6[2],"%d   ",allFs[i].ub);

        }

        if (allFs[i].fb==-1)

        {

            sprintf(buf6[3],"N/A   ");

        }

        else

        {

            sprintf(buf6[3],"%d   ",allFs[i].fb);

        }

        if (allFs[i].usage==NULL)

        {

            sprintf(buf6[4],"N/A   ");

        }

        else

        {

            sprintf(buf6[4],"%s   ",allFs[i].usage);

        }

        if (allFs[i].point==NULL)

        {

            sprintf(buf6[50],"N/A   ");

        }

        else

        {

            sprintf(buf6[5],"%s   ",allFs[i].point);

        }

        gtk_list_store_append(list_p5, &iter_p5);

        gtk_list_store_set(list_p5, &iter_p5,

                0,buf6[0],

                1,buf6[1],

                2,buf6[2],

                3,buf6[3],

                4,buf6[4],

                5,buf6[5],

                -1);

    }

}

page5Generate()

{

    /* create a 6?column list */

    list_p5 = gtk_list_store_new(6,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING);

    updatePage5();

    /* create tree view for the list */

    view_p5 = g_object_new(GTK_TYPE_TREE_VIEW,

            "model", list_p5,

            "reorderable", TRUE,

            NULL);

    gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(view_p5),TRUE);

    /* create and initialize text renderer for cells */

    text_renderer_p5_1 = gtk_cell_renderer_text_new();

    g_object_set(text_renderer_p5_1, "font", "URW Gothic L","weight",1500,NULL);

    text_renderer_p5_2 = gtk_cell_renderer_text_new();

    g_object_set(text_renderer_p5_2, "font", "URW Gothic L",NULL);

    text_renderer_p5_3 = gtk_cell_renderer_text_new();

    g_object_set(text_renderer_p5_3, "font", "URW Gothic L",NULL);

    text_renderer_p5_4 = gtk_cell_renderer_text_new();

    g_object_set(text_renderer_p5_4, "font", "URW Gothic L",NULL);

    text_renderer_p5_5 = gtk_cell_renderer_text_new();

    g_object_set(text_renderer_p5_5, "font", "URW Gothic L",NULL);

    text_renderer_p5_6 = gtk_cell_renderer_text_new();

    g_object_set(text_renderer_p5_6, "font", "Purisa",NULL);

    /* create column views */

    name_column_p5 = gtk_tree_view_column_new_with_attributes("Name",text_renderer_p5_1,"text", 0,NULL);

    g_object_set(name_column_p5,

            "resizable", TRUE,

            "clickable", FALSE,

            "reorderable", TRUE,

            NULL);

    ab_column_p5 = gtk_tree_view_column_new_with_attributes("Size(MB)",text_renderer_p5_2,"text", 1,NULL);

    g_object_set(ab_column_p5,

            "resizable", TRUE,

            "clickable", FALSE,

            "reorderable", TRUE,

            NULL);

    ub_column_p5 = gtk_tree_view_column_new_with_attributes("Used(MB)",text_renderer_p5_3,"text", 2,NULL);

    g_object_set(ub_column_p5,

            "resizable", TRUE,

            "clickable", FALSE,

            "reorderable", TRUE,

            NULL);

    fb_column_p5 = gtk_tree_view_column_new_with_attributes("Free(MB)",text_renderer_p5_4,"text", 3,NULL);

    g_object_set(fb_column_p5,

            "resizable", TRUE,

            "clickable", FALSE,

            "reorderable", TRUE,

            NULL);

    usage_column_p5 = gtk_tree_view_column_new_with_attributes("Used Percentage",text_renderer_p5_5,"text", 4,NULL);

    g_object_set(usage_column_p5,

            "resizable", TRUE,

            "clickable", FALSE,

            "reorderable", TRUE,

            NULL);

    point_column_p5 = gtk_tree_view_column_new_with_attributes("Mount Point",text_renderer_p5_6,"text", 5,NULL);

    g_object_set(point_column_p5,

            "resizable", TRUE,

            "clickable", FALSE,

            "reorderable", TRUE,

            NULL);

    /* insert columns into the view */

    gtk_tree_view_append_column(view_p5,name_column_p5);

    gtk_tree_view_append_column(view_p5,ab_column_p5);

    gtk_tree_view_append_column(view_p5,ub_column_p5);

    gtk_tree_view_append_column(view_p5,fb_column_p5);

    gtk_tree_view_append_column(view_p5,usage_column_p5);

    gtk_tree_view_append_column(view_p5,point_column_p5);

    /* put everything into a scrolled window */

    scrolled_window_p5 = g_object_new(GTK_TYPE_SCROLLED_WINDOW, NULL);

    gtk_container_add(GTK_CONTAINER(scrolled_window_p5), GTK_WIDGET(view_p5));

    gtk_table_attach(GTK_TABLE(page_table[4]),GTK_WIDGET(scrolled_window_p5),

            0,gridQuanH,

            0,gridQuanV/10*9,

            GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL,

            10,10

            );

    page5Frame=g_object_new(GTK_TYPE_FRAME, "label", "Main Filesystem Overall View", NULL);

    gtk_table_attach(GTK_TABLE(page_table[4]),GTK_WIDGET(page5Frame),

            0,gridQuanH,

            gridQuanV/10*9,gridQuanV,

            GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL,

            10,5

            );

    sprintf(fsOverallDataBuffer,"In total, %d main filesystem found",fsNum);

    page5Label=gtk_label_new(fsOverallDataBuffer);

    gtk_label_set_justify(GTK_LABEL(page5Label),GTK_JUSTIFY_CENTER);

    markup1 = g_markup_printf_escaped ("<span font_desc=\"URW Palladio Bold 17\">In total, %d main filesystem found.</span>",fsNum);

    gtk_label_set_markup (GTK_LABEL (page5Label), markup1);

    g_free (markup1);

    gtk_table_attach(GTK_TABLE(page_table[4]),GTK_WIDGET(page5Label),

            0,gridQuanH,

            gridQuanV/10*9,gridQuanV,

            GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL,

            10,0

            );

}

更多相关推荐:
操作系统实验报告 完全版

《计算机操作系统》实验报告班级:姓名:学号:实验一进程控制与描述一、实验目的通过对Windows2000编程,进一步熟悉操作系统的基本概念,较好地理解Windows2000的结构。通过创建进程、观察正在运行的进…

操作系统实验报告

操作系统实验报告实验名称理解UNIXLINUXShell及UNIX的进程树成绩专业班级计科姓名学号联系电话实验日期20xx年12月5日实验报告日期20xx年12月5日一实验名称理解UNIXLINUXShell及...

操作系统实验报告

目录实验一进程的创建2实验二进程控制3实验三进程的管道通信4实验四消息通信6实验五进程调度算法8实验六FIFO页面置换算法12实验七LRU页面置换算法14实验八磁盘调度18实验一进程的创建1一实验目的编写一段程...

操作系统实验报告

操作系统实验报告学号姓名班级实验一实验报告实验名称并发程序设计实验1实验目的掌握在程序中创建新进程的方法观察并理解多道程序并发执行的现象实验原理fork建立子进程子进程得到父进程地址空间的一个复制返回值成功时该...

计算机操作系统课程设计报告

《操作系统原理》实验报告院(部):管理工程学院专业:信息管理与信息系统实验项目:实验一二三五班级:信管102姓名:学号:目录引言.........................................…

操作系统课程设计实验报告

操作系统课程设计实验报告姓名学号班级地点20xx年月日任务说明共完成四个任务任务一IO系统调用开销比较任务二实现一个简单的shell任务三进程线程同步任务四文件内容的并行搜索其中任务一完成了标准c和unix下的...

操作系统实验报告

郑州航空工业管理学院计算机科学与应用系课程设计报告操作系统原理操作系统课程设计目录1题目简述22需求分析221设计思想222要求323任务324运行环境325开发工具33概要设计与详细设计331系统流程图332...

操作系统实验报告一

计算机操作系统实验报告一姓名学号实验环境MicrosoftVisualC60实验目的进程是操作系统最重要的概念之一进程调度又是操作系统核心的主要内容本实习要求学生独立地用高级语言编写和调试一个简单的进程调度程序...

操作系统实验报告

计算机操作系统实验二进程调度1目的和要求通过这次实验理解进程调度的过程进一步掌握进程状态的转变进程调度的策略进一步体会多道程序并发执行的特点并分析具体的调度算法的特点掌握对系统性能的评价方法2实验内容阅读教材计...

操作系统实验报告

操作系统上机实验报告班级学号姓名实验地点E区203实验时间20xx92620xx125实验一进程的建立实验目的创建进程及子进程在父子进程间实现进程通信实验软硬件环境Linux实验内容创建进程并显示标识等进程控制...

操作系统实验报告

实验二进程管理一进程的创建实验思考题1系统是怎样创建进程的解linux系统创建进程都是用fork系统调用创建子进程2当首次调用新创建进时其入口在哪里解由fork系统调用创建的新进程被称为子进程该函数被调用一次但...

操作系统原理实验报告(最终版)

键入文字课程名称学院专业班姓名学号指导教师XX学校实验报告20xx年3月目录实验1进程管理3一实验目的3二实验内容3三实验要求3四程序说明和程序流程图4五程序代码5六程序运行结果及分析7七指导教师评议8实验2进...

操作系统实验报告(38篇)