资源描述:
《假脱机打印程序》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、#include#include#include#include#include#include#defineMAX_THREAD3#defineBF_initialize_require_memory_listFF_initialize_require_memory_list#defineWF_initialize_require_memory_listFF_initialize_require_memory_list#defineBF_initializ
2、e_thread_residence_memory_listFF_initialize_thread_residence_memory_list#defineWF_initialize_thread_residence_memory_listFF_initialize_thread_residence_memory_list#defineWF_delete_freearea_listFF_delete_freearea_list#defineBF_delete_freearea_listFF_delete_freearea_list#defineWF_delete_
3、require_memory_listFF_delete_require_memory_list#defineBF_delete_require_memory_listFF_delete_require_memory_list#defineWF_delete_thread_residence_memory_listFF_delete_thread_residence_memory_list#defineBF_delete_thread_residence_memory_listFF_delete_thread_residence_memory_listtypedef
4、structfreearea{//表示空闲区域的数据结构structfreearea*next;//指向下一个结点的指针intstart_address;//空闲区起始地址intsize;//空闲区大小}FREEAREA;typedefstructrequire_memory{//记录线程申请内存的数据结构structrequire_memory*next;//指向下一个结点的指针charthread_name[10];//线程名intsize;//申请内存大小(以KB为单位)intduration;//在内存的驻留时间(以秒为单位)}REQUIRE_MEMORY;
5、typedefstructthread_residence_memory{//描述线程驻留区的数据结构structthread_residence_memory*next;//指向下一个结点的指针charthread_name[10];//线程名intstart_address;//驻留区起始地址intsize;//驻留区大小}THREAD_RESIDENCE_MEMORY;FREEAREAinit_free_area_table[5]={//测试数据:初始空闲区表{NULL,10,10},{NULL,40,30},{NULL,80,5},{NULL,145,15}
6、,{NULL,180,20}};REQUIRE_MEMORYinit_thread_require_memory_table[3]={//测试数据:初始内存申请表{NULL,"thread_1",20,4},{NULL,"thread_2",10,5},{NULL,"thread_3",5,6}};//测试数据:初始线程驻留区表THREAD_RESIDENCE_MEMORYinit_thread_residence_memory_table[5]={{NULL,"a",0,10},{NULL,"b",20,20},{NULL,"c",70,10},{NULL,"d"
7、,85,60},{NULL,"e",160,20}};FREEAREA*p_free_area_list=NULL;//空闲区链首REQUIRE_MEMORY*p_thread_require_memory_queue=NULL;//内存申请队列队首THREAD_RESIDENCE_MEMORY*p_thread_residence_memory_list=NULL;//线程驻留区链首THREAD_RESIDENCE_MEMORY*tail_thread_residence_memory_list=NULL;//线程驻留区链尾CRITICAL_SECTIONCS