use nix build & meson & zlog

This commit is contained in:
Rongsong Shen 2025-11-03 18:19:59 +08:00
parent 0123623742
commit 346768a144
60 changed files with 13739 additions and 0 deletions

61
src/include/vtaskmgr.h Normal file
View file

@ -0,0 +1,61 @@
#if !defined(_VTASKMGR_H_)
#define _VTASKMGR_H_ 1
#include <pthread.h>
#include <stddef.h>
#include "dataq.h"
#include "mylock.h"
#include "netio.h"
#include "request.h"
typedef int (*vtask_func_t)(void*);
typedef struct {
void* owner;
ioctx_t ctx;
int vcpu;
vtask_func_t entry;
} vtask_t;
#define ITPTR_TO_VTASK(p) \
((vtask_t*)(((char*)p) - offsetof(ioctx_t, link) - offsetof(vtask_t, ctx)))
typedef enum {
VCPU_IDLE = 0,
VCPU_BUSY,
VCPU_ERR
} vcpu_state_t;
typedef struct {
int cpuid;
vcpu_state_t state;
void* owner;
cbuf_t wbuf;
vtask_t* task;
pthread_t vcpu;
} vcpu_t;
typedef struct {
int n_vcpus;
pthread_t dispatcher;
vcpu_t* vcpus;
cbuf_t wbuf;
cbuf_t wtbuf; /* used to wake up vtaskmgr to check tasks */
dataq_t taskq;
} vtaskmgr_t;
extern vtask_t* vtask_alloc();
extern int vtask_init(vtask_t*, vtask_func_t, endpoint_t*);
extern void vtask_fini(vtask_t*);
extern int vtask_enq(vtaskmgr_t*, vtask_t*);
extern int vtaskmgr_init(vtaskmgr_t*, int);
extern int vtaskmgr_start(vtaskmgr_t*);
extern void vtaskmgr_fini(vtaskmgr_t*);
extern void vtaskmgr_wait(vtaskmgr_t *);
extern void vtaskmgr_wakeup(vtaskmgr_t *);
#endif