Skip to content

Commit dcf40f6

Browse files
committed
update example unikernel to show mounted mappings
1 parent f4c9da8 commit dcf40f6

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

example/src/main.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
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+
std::println();
8+
9+
std::println("Current virtual mappings:");
10+
for (const auto& entry : os::mem::vmmap())
11+
std::println(" {}", entry.second.to_string());
12+
std::println();
13+
14+
std::println("Tip: Try changing how much memory you give to the service in vm.json");
15+
std::println("Service done. Shutting down...");
16+
817
os::shutdown();
918
}

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": 128
3+
}

0 commit comments

Comments
 (0)