Jun
Jun
@Panlq 嗯嗯,我用的是python3,2和3的一些实现不太一样
# sock_create ```c // net/socket.c /** * sock_create - creates a socket * @family: protocol family (AF_INET, ...) * @type: communication type (SOCK_STREAM, ...) * @protocol: protocol (0, ...) *...
# sock_map_fd sock_map_fd 将为 socket 打开一个文件,并返回文件描述符 fd。 ```c // net/socket.c static int sock_map_fd(struct socket *sock, int flags) { struct file *newfile; int fd = get_unused_fd_flags(flags); if (unlikely(fd < 0)) {...
# inet_create ```c // net/ipv4/af_inet.c /* * Create an inet socket. */ static int inet_create(struct net *net, struct socket *sock, int protocol, int kern) { struct sock *sk; struct inet_protosw...
## 创建 ```c // 5.0/src/quicklist.c /* Create a new quicklist. * Free with quicklistRelease(). */ quicklist *quicklistCreate(void) { struct quicklist *quicklist; quicklist = zmalloc(sizeof(*quicklist)); quicklist->head = quicklist->tail = NULL; quicklist->len...
## 添加 ```c // 5.0/src/quicklist.c /* Wrapper to allow argument-based switching between HEAD/TAIL pop */ void quicklistPush(quicklist *quicklist, void *value, const size_t sz, int where) { if (where == QUICKLIST_HEAD)...
@yetingsky 膜拜yeting老师 = =
@leefige 感谢纠正
## 进程优先级 > Linux 采用了两种不同的优先级范围。第一种是用 nice 值,它的范围是从 -20 到 +19,默认值为 0;越大的 nice 值意味着更低的优先级。 > 第二种范围是实时优先级,其值是可配置的,默认情况下它的变化范围是从 0 到 99。与 nice 值意义相反,越高的实时优先级数值意味着进程优先级越高。任何实时进程的优先级都高于普通进程,也就是说实时优先级和 nice 优先级处于互不相交的两个范畴。 > ---《Linux 内核设计与实现》 task_struct 中具体表示优先级的4个值: - static_prio 表示进程的静态优先级,在...
## 调度策略 我们来看下 Linux 中提供了以下几种调度策略: ```c // tags/v4.18 - include/uapi/linux/sched.h /* * Scheduling policies */ #define SCHED_NORMAL 0 #define SCHED_FIFO 1 #define SCHED_RR 2 #define SCHED_BATCH 3 /* SCHED_ISO: reserved...