資源簡介
本系統(tǒng)是為了能夠使操作系統(tǒng)的進(jìn)程能夠正確地共享資源,并且不會(huì)因?yàn)楣蚕碣Y源而陷入死鎖,對此,采用銀行家算法。把操作系統(tǒng)看作是銀行家,操作系統(tǒng)管理的資源相當(dāng)于銀行家管理的資金,進(jìn)程向操作系統(tǒng)請求分配資源相當(dāng)于用戶向銀行家貸款。操作系統(tǒng)按照銀行家制定的規(guī)則為進(jìn)程分配資源,當(dāng)進(jìn)程首次申請資源時(shí),要測試該進(jìn)程對資源的最大需求量,如果系統(tǒng)現(xiàn)存的資源可以滿足它的最大需求量則按當(dāng)前的申請量分配資源,否則就推遲分配。當(dāng)進(jìn)程在執(zhí)行中繼續(xù)申請資源時(shí),先測試該進(jìn)程已占用的資源數(shù)與本次申請的資源數(shù)之和是否超過了該進(jìn)程對資源的最大需求量。若超過則拒絕分配資源,若沒有超過則再測試系統(tǒng)現(xiàn)存的資源能否滿足該進(jìn)程尚需的最大資源量,若能滿足則按當(dāng)前的申請量分配資源,否則也要推遲分配

代碼片段和文件信息
//?Banker.cpp?:?Defines?the?class?behaviors?for?the?application.
//
#include?“stdafx.h“
#include?“Banker.h“
#include?“BankerDlg.h“
#include?“initdlg.h“
#ifdef?_DEBUG
#define?new?DEBUG_NEW
#undef?THIS_FILE
static?char?THIS_FILE[]?=?__FILE__;
#endif
extern?int?ResourceNumber;
extern?int?ProcessNumber;
/////////////////////////////////////////////////////////////////////////////
//?CBankerApp
BEGIN_MESSAGE_MAP(CBankerApp?CWinApp)
//{{AFX_MSG_MAP(CBankerApp)
//?NOTE?-?the?ClassWizard?will?add?and?remove?mapping?macros?here.
//????DO?NOT?EDIT?what?you?see?in?these?blocks?of?generated?code!
//}}AFX_MSG
ON_COMMAND(ID_HELP?CWinApp::onhelp)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
//?CBankerApp?construction
CBankerApp::CBankerApp()
{
//?TODO:?add?construction?code?here
//?Place?all?significant?initialization?in?InitInstance
}
/////////////////////////////////////////////////////////////////////////////
//?The?one?and?only?CBankerApp?object
CBankerApp?theApp;
/////////////////////////////////////////////////////////////////////////////
//?CBankerApp?initialization
BOOL?CBankerApp::InitInstance()
{
AfxEnableControlContainer();
//?Standard?initialization
//?If?you?are?not?using?these?features?and?wish?to?reduce?the?size
//??of?your?final?executable?you?should?remove?from?the?following
//??the?specific?initialization?routines?you?do?not?need.
#ifdef?_AFXDLL
Enable3dControls(); //?Call?this?when?using?MFC?in?a?shared?DLL
#else
Enable3dControlsStatic(); //?Call?this?when?linking?to?MFC?statically
#endif
InitDlg?InitDlg;
int?respone?=?InitDlg.DoModal();
if(respone?==?IDOK)
{
ResourceNumber?=?InitDlg.m_Init_ResourceNumber;
ProcessNumber?=?InitDlg.m_Init_ProcessNumber;
CBankerDlg?dlg;
m_pMainWnd?=?&dlg;
SetDialogBkColor(RGB(192192192)RGB(00255));
int?nResponse?=?dlg.DoModal();
if?(nResponse?==?IDOK)
{
//?TODO:?Place?code?here?to?handle?when?the?dialog?is
//??dismissed?with?OK
}
else?if?(nResponse?==?IDCANCEL)
{
//?TODO:?Place?code?here?to?handle?when?the?dialog?is
//??dismissed?with?Cancel
}
}
//?Since?the?dialog?has?been?closed?return?FALSE?so?that?we?exit?the
//??application?rather?than?start?the?application‘s?message?pump.
return?FALSE;
}
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件?????????33??2010-07-07?09:15??Allocation.txt
?????文件??????????5??2010-07-07?10:14??Available.txt
?????文件?????????34??2010-07-07?09:16??Max.txt
?????文件?????????20??2010-07-11?22:00??ReadMe.txt
?????文件?????????33??2010-07-07?09:15??Banker\Allocation.txt
?????文件??????????5??2010-07-07?10:14??Banker\Available.txt
?????文件??????38780??2010-07-18?21:29??Banker\Banker.aps
?????文件???????2044??2010-07-18?21:29??Banker\Banker.clw
?????文件???????2390??2010-07-05?08:29??Banker\Banker.cpp
?????文件???????5593??2010-07-05?09:50??Banker\Banker.dsp
?????文件????????564??2010-07-04?14:55??Banker\Banker.dsw
?????文件???????1324??2010-07-04?14:45??Banker\Banker.h
?????文件?????492544??2010-07-18?21:29??Banker\Banker.ncb
?????文件??????49664??2010-07-18?21:29??Banker\Banker.opt
?????文件???????2500??2010-07-18?21:29??Banker\Banker.plg
?????文件??????11048??2010-07-18?21:29??Banker\Banker.rc
?????文件??????24393??2010-07-07?13:55??Banker\BankerDlg.cpp
?????文件???????2367??2010-07-07?09:37??Banker\BankerDlg.h
?????文件?????159861??2010-07-18?21:29??Banker\Debug\Banker.exe
?????文件?????315764??2010-07-18?21:29??Banker\Debug\Banker.ilk
?????文件??????39807??2010-07-18?21:29??Banker\Debug\Banker.obj
?????文件????5568864??2010-07-18?21:29??Banker\Debug\Banker.pch
?????文件?????435200??2010-07-18?21:29??Banker\Debug\Banker.pdb
?????文件???????4320??2010-07-18?21:29??Banker\Debug\Banker.res
?????文件?????131863??2010-07-18?21:29??Banker\Debug\BankerDlg.obj
?????文件??????25101??2010-07-18?21:29??Banker\Debug\font.obj
?????文件??????20542??2010-07-18?21:29??Banker\Debug\InitDlg.obj
?????文件?????147814??2010-07-18?21:29??Banker\Debug\msflexgrid.obj
?????文件??????17643??2010-07-18?21:29??Banker\Debug\picture.obj
?????文件??????13796??2010-07-18?21:29??Banker\Debug\rowcursor.obj
............此處省略26個(gè)文件信息
評論
共有 條評論