---
# System prepended metadata

title: XENBUS guide

---

# XENBUS guide

A comparison between MiniOS and ZephyrOS. Zephyr OS has taken alot of inspirtation in its implementations from MiniOS, therefore we will look at the implementations in both OSes to get a understanding how we can utilize XenBus, Evthcn and GNttab in Zephyr.

## Xenbus INIT (MiniOS)

To initalize xenbus we need a **xenbus thread**. Line 364 creates creates a thread with a thread routine **xenbus_thread_func**.

We also need to bind the xenbus_evtchn which is a pre-defined evtchn that can be fetched using the hypercall **HYPERVISOR_hvm_op**. we bind the eventchannel to a service routine **xenbus_evtchn_handler** using the function **bind_evtchn** at line 366.

The last thing we do is to unmask the eventchannel using **unmask_evtchn**

![](https://i.imgur.com/YhWXPfk.png)

### create_thread
The first function used is create_thread which creates a thread "xenstore" with a thread routine **xenbus_thread_func**. 

![](https://i.imgur.com/Te1DCR1.png)

![](https://i.imgur.com/3uojwMO.png)

![](https://i.imgur.com/Qc1M6bv.png)


The Thread is basically always waiting for an event see line 228. wait_event is a macro defined as 

![](https://i.imgur.com/puqtI5l.png)


According to this implementation, xenbus or atleast xenstore is based on a ringbuffer. Some common terminology for future uses includes

- rsp_prod: response producer
- rsp_cons: response costumer
- req_prod: request producer
- req_cons: request consumer

![](https://i.imgur.com/9O4uTB1.png)


### bind_evtchn







### unmask_evtchn


