Skip to content

Files

Latest commit

439dcc7 · May 9, 2020

History

History
23 lines (18 loc) · 959 Bytes

29.md

File metadata and controls

23 lines (18 loc) · 959 Bytes

Pthread 复习题

原文:https://github.com/angrave/SystemProgramming/wiki/Pthread-Review-Questions

话题

  • pthread 生命周期
  • 每个线程都有一个栈
  • 从线程捕获返回值
  • 使用pthread_join
  • 使用pthread_create
  • 使用pthread_exit
  • 在什么条件下进程会退出

问题

  • 创建 pthread 会发生什么? (你不需要进入超级细节)
  • 每个线程的栈在哪里?
  • 如果给出pthread_t,你如何得到一个回报值?线程可以设置返回值的方式是什么?如果您丢弃返回值会发生什么?
  • 为什么pthread_join很重要(想想栈空间,寄存器,返回值)?
  • 在正常情况下pthread_exit会做什么(即你不是最后一个线程)?调用 pthread_exit 时会调用哪些其他函数?
  • 给我三个条件,在这个条件下多线程进程将退出。你还能想到吗?
  • 什么是令人尴尬的并行问题?