This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
public class Player : MonoBehaviour { | |
public enum PlayerState {MOVING_UP, MOVING_DOWN, MOVING_LEFT, MOVING_RIGHT}; | |
public PlayerState state; | |
public float speed; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
public class GridMove : MonoBehaviour { | |
public enum PlayerState {MOVING, STOPPED, TURNING}; | |
public enum Direction {UP, DOWN, LEFT, RIGHT}; | |
public PlayerState state; | |
public Direction facing; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using UnityEngine; | |
class GridMove : MonoBehaviour { | |
public float moveSpeed; | |
public float gridSize; | |
public enum PlayerState {MOVING, STOPPED}; | |
public enum Direction {UP, DOWN, LEFT, RIGHT}; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void process_manager::create_processes(int n) { | |
int pid; | |
for(int i = 1; i <= n; ++i) { | |
//create pipes before forking | |
if(pipe(parent_to_child) == -1) { | |
cout << "Error creating pipe!" << endl; | |
exit(); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool process_manager::check_safe(int* _avail, int** _alloc, int** _max) { | |
int i, j; //loop counters | |
int* work = new int[num_resources]; | |
bool* finish = new bool[num_processes]; | |
//set finish[i] to false | |
for(i = 0; i < num_processes; i++) { | |
finish[i] = false; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int VirtualMemoryManager::convert_from_hex(string h) { | |
h = h.substr(2); //truncate the 0x portion | |
int result = 0; | |
//magic, converts to int, stores in result | |
sscanf(h.c_str(), "%x", &result); | |
return result; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int VirtualMemoryManager::get_mask(int last_x_bits) { | |
int mask = 0; | |
for(int i = 0; i < last_x_bits; i++) { | |
mask += pow(2, i); | |
} | |
return mask; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if(virtual_memory[index_to_access] == -1) { | |
//not in ram | |
//it's on the disk | |
//call page fault handler | |
int new_frame = page_fault_handler(); | |
//clear out old frame info | |
if(ram[new_frame] != -1) { | |
virtual_memory[ ram[new_frame] ] = -1; | |
} | |
//mark page table entry |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for(int i = 0; i < frames_per_process; i++) { | |
int cur_frame = frames_per_process*pid_offset + i; | |
if(ram[cur_frame] == -1) { | |
//empty slot found in ram | |
return cur_frame; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <fstream> | |
#include <string> | |
#include <ctime> | |
#include <cstdlib> | |
#include <time.h> | |
#include "VirtualMemoryManager.h" | |
using namespace std; |
OlderNewer