一、数据结构文件common.h解析

1、_st_clist循环队列

//循环队列定义
typedef struct _st_clist {struct _st_clist *next;struct _st_clist *prev;
} _st_clist_t;

包含该队列的对象,后续都可以根据该队列在对象中的偏移位置来计算对象的地址。

2、_st_stack栈

typedef struct _st_stack {_st_clist_t links;char *vaddr;                /* Base of stack's allocated memory */int  vaddr_size;            /* Size of stack's allocated memory */int  stk_size;              /* Size of usable portion of the stack */char *stk_bottom;           /* Lowest address of stack's usable portion */char *stk_top;              /* Highest address of stack's usable portion */void *sp;                   /* Stack pointer from C's point of view */
#ifdef __ia64__void *bsp;                  /* Register stack backing store pointer */
#endif
} _st_stack_t;

sp是C分配出来的指针的起始地址,其他成员值都是基于此地址的。

3、_st_cond条件

typedef struct _st_cond {_st_clist_t wait_q;       /* Condition variable wait queue */
} _st_cond_t;

条件变量等待队列

4、_st_thread协程

struct _st_thread {int state;                  /* Thread's state */int flags;                  /* Thread's flags */void *(*start)(void *arg);  /* The start function of the thread */void *arg;                  /* Argument of the start function */void *retval;               /* Return value of the start function */_st_stack_t *stack;         /* Info about thread's stack */_st_clist_t links;          /* For putting on run/sleep/zombie queue */_st_clist_t wait_links;     /* For putting on mutex/condvar wait queue */
#ifdef DEBUG_st_clist_t tlink;          /* For putting on thread queue */
#endifst_utime_t due;             /* Wakeup time when thread is sleeping */_st_thread_t *left;         /* For putting in timeout heap */_st_thread_t *right;          /* -- see docs/timeout_heap.txt for details */int heap_index;void **private_data;        /* Per thread private data */_st_cond_t *term;           /* Termination condition variable for join */jmp_buf context;            /* Thread's context */
};

5、_st_mutex互斥量

typedef struct _st_mutex {_st_thread_t *owner;        /* Current mutex owner */_st_clist_t  wait_q;        /* Mutex wait queue */
} _st_mutex_t;

6、_st_pollq  poll对象

typedef struct _st_pollq {_st_clist_t links;          /* For putting on io queue */_st_thread_t  *thread;      /* Polling thread */struct pollfd *pds;         /* Array of poll descriptors */int npds;                   /* Length of the array */int on_ioq;                 /* Is it on ioq? */
} _st_pollq_t;

7、_st_eventsys_ops网络事件

typedef struct _st_eventsys_ops {const char *name;                          /* Name of this event system */int  val;                                  /* Type of this event system */int  (*init)(void);                        /* Initialization */void (*dispatch)(void);                    /* Dispatch function */int  (*pollset_add)(struct pollfd *, int); /* Add descriptor set */void (*pollset_del)(struct pollfd *, int); /* Delete descriptor set */int  (*fd_new)(int);                       /* New descriptor allocated */int  (*fd_close)(int);                     /* Descriptor closed */int  (*fd_getlimit)(void);                 /* Descriptor hard limit */
} _st_eventsys_t;

网络事件接口封装

8、_st_vp虚拟进程

typedef struct _st_vp {_st_thread_t *idle_thread;  /* Idle thread for this vp */st_utime_t last_clock;      /* The last time we went into vp_check_clock() */_st_clist_t run_q;          /* run queue for this vp */_st_clist_t io_q;           /* io queue for this vp */_st_clist_t zombie_q;       /* zombie queue for this vp */
#ifdef DEBUG_st_clist_t thread_q;       /* all threads of this vp */
#endifint pagesize;_st_thread_t *sleep_q;      /* sleep queue for this vp */int sleepq_size;          /* number of threads on sleep queue */#ifdef ST_SWITCH_CBst_switch_cb_t switch_out_cb;    /* called when a thread is switched out */st_switch_cb_t switch_in_cb;  /* called when a thread is switched in */
#endif
} _st_vp_t;

全局虚拟进程

9、_st_netfd网络句柄

typedef struct _st_netfd {int osfd;                   /* Underlying OS file descriptor */int inuse;                  /* In-use flag */void *private_data;         /* Per descriptor private data */_st_destructor_t destructor; /* Private data destructor function */void *aux_data;             /* Auxiliary data for internal use */struct _st_netfd *next;     /* For putting on the free list */
} _st_netfd_t;

网络句柄列表

state thread协程库解析相关推荐

  1. 【Rust技术公开课】港哥Elton自主开发的协程库解析-CSDN公开课-专题视频课程

    [Rust技术公开课]港哥Elton自主开发的协程库解析-5670人已学习 课程介绍         演讲嘉宾:钟宇腾(Elton,GitHub.LinkedIn),香港大学计算机系毕业,微信游戏开发 ...

  2. 协程库st(state threads library)原理解析

    协程库state threads library(以下简称st)是一个基于setjmp/longjmp实现的C语言版用户线程库或协程库(user level thread). 这里有一个基本的协程例子 ...

  3. 一个“蝇量级” C 语言协程库

    协程(coroutine)顾名思义就是"协作的例程"(co-operative routines).跟具有操作系统概念的线程不一样,协程是在用户空间利用程序语言的语法语义就能实现逻 ...

  4. Libco是一个C/C++协程库,在微信服务中广泛使用

    Table of Contents 协程简介 协程Libco库 libco的特性 PS:CGI框架 PS:Lambda表达式 协程简介 协程这个概念其实在<操作系统>系统里面应该有了解过, ...

  5. ucontext-人人都可以实现的简单协程库

    1.干货写在前面 协程是一种用户态的轻量级线程.本篇主要研究协程的C/C++的实现. 首先我们可以看看有哪些语言已经具备协程语义: 比较重量级的有C#.erlang.golang* 轻量级有pytho ...

  6. C++协程库coroutine使用指南

    https://github.com/tonbit/coroutine是一个精巧的C++非对称协程库.库只有一个.h文件(<500行的代码),使用时也仅需要include这个头文件.但是在功能上 ...

  7. libco协程库源码解读

    2019独角兽企业重金招聘Python工程师标准>>> 协程,又被称为用户级线程,是在应用层被调度,可以减少因为调用系统调用而阻塞的线程切换的时间.目前有很多协程的实现,由于微信内部 ...

  8. Python 的协程库 greenlet 和 gevent

    greenlet 官方文档:https://greenlet.readthedocs.io/en/latest/ From:https://www.jianshu.com/u/3ab212f28d91 ...

  9. c++开源协程库libgo介绍及使用

    协程这个概念,最近这几年可是相当地流行了.尤其 go 语言问世之后,内置的协程特性,完全屏蔽了操作系统线程的复杂细节.甚至使 go 开发者"只知有协程,不知有线程"了.当然 C++ ...

最新文章

  1. Redis架构第二天:CenterOS集群、RDB和AOF、主从复制架构实践
  2. 因为名字叫True,她被苹果iCloud服务器拒绝了
  3. 过滤html标签 RemoveHTML
  4. 疾病相关数据查找,Our world in data使用指南
  5. dev c++怎么设置断点_Linux怎么挂载移动硬盘光盘U盘之案例分享
  6. linux c socket通信
  7. [ JS 进阶 ] Repaint 、Reflow 的基本认识和优化 (2)
  8. 职专计算机怎么学,浅析职业中专计算机专业计算机教学
  9. 认识星座、八大行星的观察
  10. cude的__ldg使用
  11. 【干货】京东电商推荐系统的应用实践.pdf(附下载链接)
  12. 远程调用——hessian使用入门
  13. libmodbus 开发说明
  14. COMSOL 电场与热场耦合
  15. 十三天学会C语言笔记
  16. 正则表达式(一)字符串匹配
  17. java正则表达式 问号_正则表达式问号的四种用法详解
  18. java蓝牙程序怎么调试_蓝牙BLE调试助手软件源码
  19. 【数据库】编写存储过程
  20. 蕃茄工作法 - 让你轻松应对繁忙的工作

热门文章

  1. C语言coord笔记
  2. Dom4j修改xml文件
  3. 软著申请步骤[2023]
  4. sinatra源码解读
  5. 电子商务网站功能模块汇总
  6. lgg8各个版本_LGG8ThinQ刷机包
  7. Java 求解左叶子之和
  8. 不间断电源(UPS)
  9. 好的服务如何开发设计
  10. 清华大学计算机科学与技术系分数线6,【清华大学分数线2017】2015-2016清华大学各省各专业录取分数线(6)...