Skip to content

Commit

Permalink
Added Makefile, added README.md, changed thread IDs to hardware IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
BugUser0815 committed Sep 27, 2016
1 parent 772c3a9 commit b5b1a38
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 3 deletions.
61 changes: 61 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# options: x86 arm
TOOLCHAIN_TARGET ?= arm

# options: see tool/create_builddir
GENODE_TARGET ?= foc_pbxa9

BUILD_DIR ?= build
TOOLCHAIN_BUILD_DIR ?= $(BUILD_DIR)/toolchain-$(TOOLCHAIN_TARGET)
GENODE_BUILD_DIR ?= $(BUILD_DIR)/genode-$(GENODE_TARGET)
BUILD_CONF = $(GENODE_BUILD_DIR)/etc/build.conf

all: toolchain ports platform

# ================================================================
# Genode toolchain. Only needs to be done once per target (x86/arm).
toolchain:
mkdir -p $(TOOLCHAIN_BUILD_DIR)
cd $(TOOLCHAIN_BUILD_DIR);\
../../tool/tool_chain $(TOOLCHAIN_TARGET)
#
# ================================================================


# ================================================================
# Download Genode external sources. Only needs to be done once per system.
ports: foc libports

foc:
$(MAKE) -C repos/base-foc prepare

libports:
$(MAKE) -C repos/libports prepare
#
# ================================================================


# ================================================================
# Genode build process. Rebuild subtargets as needed.
platform: genode_build_dir tasksmanager

genode_build_dir:
tool/create_builddir $(GENODE_TARGET) BUILD_DIR=$(GENODE_BUILD_DIR)
printf 'REPOSITORIES += $$(GENODE_DIR)/repos/libports\n' >> $(BUILD_CONF)
printf 'REPOSITORIES += $$(GENODE_DIR)/repos/taskmanager\n' >> $(BUILD_CONF)

task-manager:
$(MAKE) -j10 -C $(GENODE_BUILD_DIR) task-manager

# Delete build directory for all target systems. In some cases, subfolders in the contrib directory might be corrupted. Remove manually and re-prepare if necessary.
clean:
rm -rf $(BUILD_DIR)
#
# ================================================================


# ================================================================
# Run Genode with an active dom0 server.
run:
$(MAKE) -j10 -C $(GENODE_BUILD_DIR) run/taskmanager
#
# ================================================================
61 changes: 61 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# genode-taskmanager
The taskmanager is a userspace application for monitoring purpose. It shows all threads currently running on the machine, with their IDs, execution time, ram quota, ram used and overall system load.

### Building
The custom Makefile builds the entire Fiasco.OC and Genode system including its toolchain and external dependencies into a `build/` and `contrib/` directory respectively. To manually execute steps within the build process see the Makefile or the Genode documentation:
http://genode.org/documentation/developer-resources/getting_started

The toolchain installs executables to `/usr/local/genode-gcc` as part of the Genode `tool_chain` script. Everything else stays within the repository.

After a first clone of this branch run `make` once. This will do the following:

* build and install Genode toolchain for `arm` or `x86` (target `toolchain`)
* download required external libraries into the `contrib` folder (target `ports`)
* create the target-specific build directory (target `genode_build_dir`)
* build taskmanager (target `taskmanager`)

After this, only build the targets you need. Inter-target dependencies are not set properly. When changing target platform, use the make target `platform` to only rebuild `genode_build_dir` and `taskmanager`.

To run the Genode taskmanager type `make run`

The Makefile will need additional adjustments for other kernels than Fiasco.OC.

### Required packages
The following packages are required for building the Genode toolchain:

`sudo apt-get install libncurses5-dev texinfo autogen autoconf2.64 g++ libexpat1-dev flex bison gperf`

For building Genode:

`sudo apt-get install make pkg-config gawk subversion expect git`

For running Genode in QEMU:

`sudo apt-get install libxml2-utils syslinux`

For some additional ports you may need:

`sudo apt-get install xsltproc yasm iasl lynx`

### Folder structure
Custom repos:

| Folder | Description |
| ----------------------------------- | ------------------------------------------------ |
| `repos/taskmanager/` | central network module: server and task manager |
| `repos/taskmanager/run/` | run file configuration for dom0 |
| `repos/taskmanager/src/taskmanager/re/` | taskmanager |
| `repos/taskmanager/src/idle/` | idle process to show system load |

The provided Makefile creates the following directories:

| Folder | Description |
| --------------------------- | ------------------------- |
| `build/` | all build files |
| `build/toolchain-TARGET/` | Genode toolchain |
| `build/genode-TARGET/` | Genode build dir |
| `contrib/` | external Genode libraries |

### Fine-grained CPU time
The Fiasco.OC kernel by default only returns timing information at a resolution of 1ms. Granularity can be increased by changing line 51 of `build/genode-TARGET/kernel/fiasco.oc/globalconfig.out` to
`CONFIG_FINE_GRAINED_CPUTIME=y`
4 changes: 2 additions & 2 deletions repos/base-foc/src/core/include/platform_thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ namespace Genode {

Affinity::Location _location;


void _create_thread(void);
void _finalize_construction(const char *name);
bool _in_syscall(Fiasco::l4_umword_t flags);
Expand Down Expand Up @@ -179,9 +178,10 @@ namespace Genode {
*/
unsigned long long execution_time() const;


unsigned prio() const;

unsigned id() const;

/*******************************
** Fiasco-specific Accessors **
*******************************/
Expand Down
5 changes: 5 additions & 0 deletions repos/base-foc/src/core/platform_thread.cc
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,11 @@ unsigned Platform_thread::prio() const
return _prio;
}

unsigned Platform_thread::id() const
{
return _thread.local.dst();
}

Platform_thread::Platform_thread(const char *name, unsigned prio, addr_t)
: _state(DEAD),
_core_thread(false),
Expand Down
4 changes: 3 additions & 1 deletion repos/base/src/core/include/cpu_session_component.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ namespace Genode {
{
return { _session_label, _name,
_platform_thread.execution_time(),
_platform_thread.affinity() };
_platform_thread.affinity()
_platform_thread.prio(),
_platform_thread.id() };
}


Expand Down

0 comments on commit b5b1a38

Please sign in to comment.