Skip to content

Commit b3e365f

Browse files
committed
update example unikernel to show mounted mappings
1 parent 8a39558 commit b3e365f

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

example/src/main.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
1+
#include "kernel/memory.hpp"
12
#include <os>
23
#include <service>
34

45
void Service::start(const std::string& args){
5-
printf("Args = %s\n", args.c_str());
6-
printf("Try giving the service less memory, eg. 10MB in vm.json\n");
7-
printf("Service done. Shutting down...\n");
6+
std::println("Hello from the example unikernel!");
7+
8+
std::println("Current virtual mappings:");
9+
for (const auto& entry : os::mem::vmmap())
10+
std::println(" {}", entry.second.to_string());
11+
12+
std::println("Tip: Try changing how much memory you give to the service in vm.json");
13+
std::println("Service done. Shutting down...");
14+
815
os::shutdown();
916
}

example/src/vm.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"mem": 16384
3+
}

0 commit comments

Comments
 (0)