add vorgabe03 + initial bump allocator
This commit is contained in:
37
c_os/user/HeapDemo.cc
Normal file
37
c_os/user/HeapDemo.cc
Normal file
@ -0,0 +1,37 @@
|
||||
/*****************************************************************************
|
||||
* *
|
||||
* H E A P D E M O *
|
||||
* *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Demonstration der dynamischen Speicherverwaltung. *
|
||||
* *
|
||||
* Autor: Michael Schoettner, HHU, 27.12.2016 *
|
||||
*****************************************************************************/
|
||||
|
||||
#include "user/HeapDemo.h"
|
||||
#include "kernel/Allocator.h"
|
||||
#include "kernel/Globals.h"
|
||||
#include "user/MyObj.h"
|
||||
|
||||
// Hilfsfunktion: Auf Return-Taste warten
|
||||
void waitForReturn() {
|
||||
|
||||
/* hier muss Code eingefuegt werden */
|
||||
|
||||
Key key;
|
||||
do {
|
||||
kb.key_hit();
|
||||
} while (key.ascii() != '\n');
|
||||
}
|
||||
|
||||
void heap_demo() {
|
||||
|
||||
/* hier muss Code eingefuegt werden */
|
||||
allocator.dump_free_memory();
|
||||
|
||||
MyObj* a = new MyObj(5);
|
||||
allocator.dump_free_memory();
|
||||
|
||||
MyObj* b = new MyObj(10);
|
||||
allocator.dump_free_memory();
|
||||
}
|
||||
16
c_os/user/HeapDemo.h
Normal file
16
c_os/user/HeapDemo.h
Normal file
@ -0,0 +1,16 @@
|
||||
/*****************************************************************************
|
||||
* *
|
||||
* H E A P D E M O *
|
||||
* *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Demonstration der dynamischen Speicherverwaltung. *
|
||||
* *
|
||||
* Autor: Michael Schoettner, HHU, 25.9.2016 *
|
||||
*****************************************************************************/
|
||||
#ifndef __HeapDemo_include__
|
||||
#define __HeapDemo_include__
|
||||
|
||||
|
||||
void heap_demo();
|
||||
|
||||
#endif
|
||||
10
c_os/user/MyObj.h
Normal file
10
c_os/user/MyObj.h
Normal file
@ -0,0 +1,10 @@
|
||||
#ifndef __MyObj_INCLUDE_H_
|
||||
#define __MyObj_INCLUDE_H_
|
||||
|
||||
class MyObj {
|
||||
public:
|
||||
MyObj(unsigned int val) : value(val) {};
|
||||
unsigned int value;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user