⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 list.cpp

📁 操作系统的课程设计
💻 CPP
字号:
// List.cpp: implementation of the List class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "List.h"
#include <stdlib.h>
#include <iostream>
using namespace std;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

List::List(char *nodetype)
{
NodeNum=0;
status=nodetype;
ListHead=NULL;
ListTail=NULL;
}
List::~List()
{

}

int List::GetNodeNum()
{
	return NodeNum;
}
void List::SetNodeNum(int k)
{
	NodeNum=k;
	return;
}
char* List::GetListStatus()
{
	return status;
}
void List::SetStatus(char *s)
{
	status=s;
	return;
}
void List::SetListHead(PCB*pcb)
{
	ListHead=pcb;
}
void List::SetListTail(PCB*pcb)
{
	ListTail=pcb;
}
/***************************************************
取出第一个PCB,地址放在pcb中,pcb是一个PCB指针的引用
****************************************************/
Status List::GetFirstPCB(PCB * &pcb)
{
	return Ok;
}
/**************************************
将由datap所指定的PCB结构插在队列的尾部
***************************************/
Status List::AppendPCB(PCB *datap)
{
//当前状态队列中插入PCB
datap->next=NULL;
if (ListHead==NULL)
  ListHead=ListTail=datap;
else
  ListTail=ListTail->next=datap;
NodeNum++;
return Ok;
}


/*********************************************
删除内部标识为pid的PCB。
思路:①在当前链表中找到此结点
	  ②从当前链表中取出此结点,修改链表的数据
	  ③删除链表中结点和datap指向的结点
	  ④被删除的PCB的地址作为函数的返回值。
**********************************************/
PCB *List::DeletePCB(int pid)
{

	return NULL;
}

//显示链表中的所有PCB结点
void List::DisplayList()
{
PCB *temp;
temp=ListHead;
if (NodeNum==0)
	cout<<endl<<status<<"队列为空。"<<endl;	
else
{
	cout<<endl<<status<<"队列中有如下进程:"<<endl;
	while (temp!=NULL)	
	{
		cout<<"id:"<<temp->id;
		if (temp->name)
			cout<<"("<<temp->name<<")";
		else
			cout<<"(空闲)";
		cout<<"剩余时间:"<<temp->timereq-temp->time_cpu;
		if (temp!=ListTail)
			cout<<"--->";
		/////////////////////////////
		temp=temp->next;
	}
	cout<<endl;
}
 return; 
}
/****************************************************
显示地址为pcb的进程的信息
****************************************************/
void List::DisplayPCB(PCB *pcb)
{
	
}
/****************************************************
在队列中找到内部标识为pid的PCB,找到后由temp带回其地址
,其前趋的地址由pre带回。
*****************************************************/
PCB *List::FindPCB(int pid,PCB * &pre)
{
	return NULL;
}
/****************************************************
在队列中找到第pnum个PCB,其地址作为方法的返回值
*****************************************************/
PCB *List::FindPCB(int pnum)
{
	return NULL;
}
Status List::isEmpty()
{
	if (ListHead)
		return False;
	else
		return True;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -