# 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**

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



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

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

### bind_evtchn
### unmask_evtchn