+ -
当前位置:首页 → 问答吧 → 信号量被阻塞时如何进入到睡眠状态的

信号量被阻塞时如何进入到睡眠状态的

时间:2010-07-21

来源:互联网

在2.6.16code中,跟踪down()的实现,没找到最终阻塞调用down()的进程的code.那位大侠给指点下。
  1.    1. static inline void down(struct semaphore * sem)
  2.    2. {
  3.    3.         might_sleep();
  4.    4.         __asm__ __volatile__(
  5.    5.                 "# atomic down operation\n\t"
  6.    6.                 LOCK "decl %0\n\t"     /* --sem->count */
  7.    7.                 "js 2f\n"
  8.    8.                 "1:\n"
  9.    9.                 LOCK_SECTION_START("")
  10.   10.                 "2:\tlea %0,%%eax\n\t"
  11.   11.                 "call __down_failed\n\t"          <====== __down_failed
  12.   12.                 "jmp 1b\n"
  13.   13.                 LOCK_SECTION_END
  14.   14.                 :"=m" (sem->count)
  15.   15.                 :
  16.   16.                 :"memory","ax");
  17.   17. }
  18.   18. asm(
  19.   19. ".section .sched.text\n"
  20.   20. ".align 4\n"
  21.   21. ".globl __down_failed\n"
  22.   22. "__down_failed:\n\t"
  23.   23. #if defined(CONFIG_FRAME_POINTER)
  24.   24.         "pushl %ebp\n\t"
  25.   25.         "movl  %esp,%ebp\n\t"
  26.   26. #endif
  27.   27.         "pushl %edx\n\t"
  28.   28.         "pushl %ecx\n\t"
  29.   29.         "call __down\n\t"         <=== 如何实现的,没找到
  30.   30.         "popl %ecx\n\t"
  31.   31.         "popl %edx\n\t"
  32.   32. #if defined(CONFIG_FRAME_POINTER)
  33.   33.         "movl %ebp,%esp\n\t"
  34.   34.         "popl %ebp\n\t"
  35.   35. #endif
  36.   36.         "ret"
  37.   37. );
复制代码
复制代码
就跟踪到这里了,向下是怎么阻塞这个进程的?

发到了c/c++版没人回复。感觉在这里询问才是对的。

作者: 怪怪虎   发布时间: 2010-07-21

在 lib/semaphore-sleepers.c

作者: 奇门遁甲-lu   发布时间: 2010-07-21

热门下载

更多