Skip to content

Commit 53ee1be

Browse files
author
Tarek
committed
Create a swapper class skeleton
1 parent 8e11bb0 commit 53ee1be

File tree

4 files changed

+49
-0
lines changed

4 files changed

+49
-0
lines changed

StudentOS/StudentOS.vcxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,12 @@
150150
<ClCompile Include="Memory.cpp" />
151151
<ClCompile Include="OS.cpp" />
152152
<ClCompile Include="PCB.cpp" />
153+
<ClCompile Include="Swapper.cpp" />
153154
</ItemGroup>
154155
<ItemGroup>
155156
<ClInclude Include="Memory.h" />
156157
<ClInclude Include="PCB.h" />
158+
<ClInclude Include="Swapper.h" />
157159
</ItemGroup>
158160
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
159161
<ImportGroup Label="ExtensionTargets">

StudentOS/StudentOS.vcxproj.filters

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
<ClCompile Include="Memory.cpp">
3030
<Filter>Source Files</Filter>
3131
</ClCompile>
32+
<ClCompile Include="Swapper.cpp">
33+
<Filter>Source Files</Filter>
34+
</ClCompile>
3235
</ItemGroup>
3336
<ItemGroup>
3437
<ClInclude Include="PCB.h">
@@ -37,5 +40,8 @@
3740
<ClInclude Include="Memory.h">
3841
<Filter>Header Files</Filter>
3942
</ClInclude>
43+
<ClInclude Include="Swapper.h">
44+
<Filter>Header Files</Filter>
45+
</ClInclude>
4046
</ItemGroup>
4147
</Project>

StudentOS/Swapper.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#include "Swapper.h"
2+
3+
4+
5+
Swapper::Swapper()
6+
{
7+
}
8+
9+
10+
Swapper::~Swapper()
11+
{
12+
}

StudentOS/Swapper.h

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#pragma once
2+
#include <vector>
3+
#include <queue>
4+
#include "PCB.h"
5+
#include "Memory.h"
6+
using namespace std;
7+
8+
class Swapper
9+
{
10+
private:
11+
PCB* beingSwapped;
12+
vector<PCB*> LTS;
13+
queue<PCB*> swapOutQ;
14+
bool swappingIn = false;
15+
bool swappingOut = false;
16+
public:
17+
Swapper();
18+
void runFromLTS(int &, int[]);
19+
bool swapIn(int &, int[], PCB *, int);
20+
void swapOut(int &, int[], Memory&);
21+
void swapFromLTS(int &, int[], Memory&);
22+
bool isSwappingIn();
23+
bool isSwappingOut();
24+
void setSwappingIn(bool);
25+
void setSwappingOut(bool);
26+
PCB* getJobBeingSwapped();
27+
void addToLTS(PCB*);
28+
};
29+

0 commit comments

Comments
 (0)