更新时间片 -- scheduler_tick()

时钟中断处理程序中会调用函数scheduler_tick():
    函数scheduler_tick()更新当前进程的time_slice;并根据time_slice的使用情况(剩余还是耗尽),来做进一步处理.scheduler_tick( ) Keeps the time_slice counter of current up-to-date


void scheduler_tick(void)
{
    int cpu = smp_processor_id();
    runqueue_t *rq = this_rq();
    task_t *p = current;
    unsigned long long now = sched_clock();
    update_cpu_clock(p, rq, now);

更新运行队列的最新时钟中断时间戳为当前时间
|----------------------------------|
|   rq->timestamp_last_tick = now; |
|----------------------------------|

如果当前进程为本地CPU的swapper进程
|-------------------------------------------|
|   if (p == rq->idle) {                    |
|       if (wake_priority_sleeper(rq))      |
|           goto out;                       |
|       rebalance_tick(cpu, rq, SCHED_IDLE);|
|       return;                             |
|   }                                       |
|-------------------------------------------|

如果当前进程不是活跃(active)进程
|---------------------------------|
|   if (p->array != rq->active) { |
|       set_tsk_need_resched(p);  |
|       goto out;                 |
|   }                             |
|---------------------------------|

    spin_lock(&rq->lock);

如果当前进程是实时进程;如果调度策略为SCHED_RR,并且其时间片已经耗尽;为该进程重新计算时间片;清除first_time_slice域;设置task_struct.thread_info.flags域;将该任务插入其所在活跃队列的尾部.
|----------------------------------------------------------|
|   if ( rt_task(p)) {                                      |
|       if ((p->policy == SCHED_RR) && !--p->time_slice) { |
|           p->time_slice = task_timeslice(p);             |
|           p->first_time_slice = 0;                       |
|           set_tsk_need_resched(p);                       |
|           requeue_task(p, rq->active);                   |
|       }                                                  |
|       goto out_unlock;                                   |
|   }                                                      |
|----------------------------------------------------------|


当前进程为普通进程,如果其时间片已经耗尽;将该进程从活跃队列中删除;设置task_struct.thread_info.flags域;重新计算动态优先级prio;重新计算时间片;清除first_time_slice域;如果过期队列为空,将更新 runqueue.expired_timestamp;Inserts the current process either in the active set or in the expired set
|------------------------------------------------------------|
|   if (!--p->time_slice) {                                  |
|       dequeue_task(p, rq->active);                         |
|       set_tsk_need_resched(p);                             |
|       p->prio = effective_prio(p);                         |
|       p->time_slice = task_timeslice(p);                   |
|       p->first_time_slice = 0;                             |
|                                                            |
|       if (!rq->expired_timestamp)                          |
|           rq->expired_timestamp = jiffies;                 |
|       if (! TASK_INTERACTIVE(p) || EXPIRED_STARVING(rq)) {  |
|           enqueue_task(p, rq->expired);                    |
|           if (p->static_prio < rq->best_expired_prio)      |
|               rq->best_expired_prio = p->static_prio;      |
|       } else                                               |
|           enqueue_task(p, rq->active);                     |
|------------------------------------------------------------|

如果时间片没有耗尽,并且剩余时间片过长;则将该进程插入其所在队列的尾部;并设置task_struct.thread_info.flags域
if the time quantum is not exhausted (current->time_slice is not zero), checks whether the remaining time slice of the current process is too long.
|-----------------------------------------------------------------------------|
|   } else {                                                                  |
|       if ( TASK_INTERACTIVE(p) &&                                           |
|         !((task_timeslice(p) - p->time_slice) % TIMESLICE_GRANULARITY(p)) &&|
|         (p->time_slice >= TIMESLICE_GRANULARITY(p)) &&                      |
|         (p->array == rq->active)) {                                         |
|           requeue_task(p, rq->active);                                      |
|                                                                             |
|           set_tsk_need_resched(p);                                          |
|       }                                                                     |
|   }                                                                         |
|-----------------------------------------------------------------------------|
out_unlock:
    spin_unlock(&rq->lock);
out:
    rebalance_tick(cpu, rq, NOT_IDLE);
}





 
  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
好的,请允许我一一解释这些编译参数的含义。 1. --prefix=${PATH_INSTALL}/nginx 这个参数指定了 nginx 安装的路径。在这里,${PATH_INSTALL} 是一个变量,代表 nginx 安装的根目录。例如,如果 ${PATH_INSTALL} 被设置为 /usr/local,则 nginx 将会被安装到 /usr/local/nginx 目录下。 2. --user=nginx 这个参数指定了 nginx 进程运行的用户。在这里,nginx 进程将会以 nginx 用户的身份运行。 3. --group=nginx 这个参数指定了 nginx 进程运行的用户组。在这里,nginx 进程将会以 nginx 用户组的身份运行。 4. --with-http_ssl_module 这个参数启用了 nginx 的 SSL 功能,使得 nginx 能够处理 HTTPS 请求。 5. --with-http_realip_module 这个参数启用了 nginx 的真实 IP 功能,使得 nginx 能够获取客户端的真实 IP 地址。 6. --with-http_addition_module 这个参数启用了 nginx 的响应内容添加功能,使得 nginx 能够在 HTTP 响应中添加额外的内容。 7. --with-http_sub_module 这个参数启用了 nginx 的响应内容替换功能,使得 nginx 能够在 HTTP 响应中替换指定的内容。 8. --with-http_dav_module 这个参数启用了 nginx 的 WebDAV 功能,使得 nginx 能够处理 WebDAV 请求。 9. --with-http_flv_module 这个参数启用了 nginx 的 FLV 视频流功能,使得 nginx 能够处理 FLV 视频流请求。 10. --with-http_mp4_module 这个参数启用了 nginx 的 MP4 视频流功能,使得 nginx 能够处理 MP4 视频流请求。 11. --with-http_gunzip_module 这个参数启用了 nginx 的 Gzip 解压缩功能,使得 nginx 能够解压缩 Gzip 压缩的响应内容。 12. --with-http_gzip_static_module 这个参数启用了 nginx 的 Gzip 静态文件压缩功能,使得 nginx 能够对静态文件进行 Gzip 压缩。 13. --with-http_random_index_module 这个参数启用了 nginx 的随机索引功能,使得 nginx 能够在目录索引中随机显示文件。 14. --with-http_secure_link_module 这个参数启用了 nginx 的安全链接功能,使得 nginx 能够生成基于时间戳的安全链接。 15. --with-http_stub_status_module 这个参数启用了 nginx 的状态页面功能,使得 nginx 能够在浏览器中显示当前服务器的状态信息。 16. --with-http_auth_request_module 这个参数启用了 nginx 的认证请求功能,使得 nginx 能够向另一个服务器发送认证请求。 17. --with-threads 这个参数启用了 nginx 的线程池功能,使得 nginx 能够处理并发请求。 18. --with-stream 这个参数启用了 nginx 的流模块功能,使得 nginx 能够处理 TCP 和 UDP 流量。 19. --with-stream_ssl_module 这个参数启用了 nginx 的流 SSL 功能,使得 nginx 能够处理加密的 TCP 流量。 20. --with-http_slice_module 这个参数启用了 nginx 的分片功能,使得 nginx 能够将大文件分成多个小块进行传输。 21. --with-file-aio 这个参数启用了 nginx 的异步文件 I/O 功能,使得 nginx 能够异步读取文件。 22. --with-http_v2_module 这个参数启用了 nginx 的 HTTP/2 功能,使得 nginx 能够处理 HTTP/2 请求。 23. --with-pcre 这个参数启用了 PCRE 库,使得 nginx 能够使用正则表达式进行匹配操作。 24. --with-openssl=/www/server/nginx/src/openssl 这个参数指定了 OpenSSL 库的路径,使得 nginx 能够使用 OpenSSL 库进行加密操作。 25. --with-stream_ssl_preread_module 这个参数启用了 nginx 的流 SSL 预读功能,使得 nginx 能够在客户端发送 SSL 握手之前识别出 SSL 流量。 26. --with-http_image_filter_module 这个参数启用了 nginx 的图像处理功能,使得 nginx 能够处理图像文件。 27. --with-ipv6 这个参数启用了 IPv6 功能,使得 nginx 能够处理 IPv6 地址。 28. --with-ld-opt=-Wl,-E 这个参数指定了链接器的选项,使得 nginx 能够在运行时动态链接库。 29. --with-cc-opt=-Wno-error 这个参数指定了编译器的选项,禁止编译器将警告视为错误。 30. --with-ld-opt=-ljemalloc 这个参数指定了链接器的选项,使得 nginx 能够使用 jemalloc 内存分配器。 31. --add-module=/www/server/nginx/src/ngx_devel_kit 这个参数添加了一个模块,这个模块是 ngx_devel_kit,它提供了一些开发工具和库,使得开发 nginx 模块更加容易。 32. --add-module=/www/server/nginx/src/lua_nginx_module 这个参数添加了一个模块,这个模块是 lua_nginx_module,它使得 nginx 能够使用 Lua 脚本进行定制化操作。 33. --add-module=/www/server/nginx/src/ngx_cache_purge 这个参数添加了一个模块,这个模块是 ngx_cache_purge,它使得 nginx 能够手动清除缓存。 34. --add-module=/www/server/nginx/src/ngx_http_substitutions_filter_module-master 这个参数添加了一个模块,这个模块是 ngx_http_substitutions_filter_module-master,它使得 nginx 能够在 HTTP 响应中替换指定的内容。 以上就是这些编译参数的详细说明。希望对您有所帮助!

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值