明 光 大 正

pintos学习笔记1

    pintos     pintos

今天我看了《煎饼侠》和《小森林》夏秋的前面一点点。
《煎饼侠》找了挺多人,挺不可思议的,看过一个人写过大鹏。

很喜欢《小森林》的感觉,像一个梦.

Thread

struct thread

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
4 kB +---------------------------------+
| kernel stack |
| | |
| | |
| V |
| grows downward |
| |
| |
| |
| |
| |
| |
| |
| |
+---------------------------------+
| magic |
| : |
| : |
| name |
| status |
| tid |
0 kB +---------------------------------+

tid

线程标识符
tid_t,int类型
从1开始,为了初始化进程

status

  • THREAD_RUNNING
    • thread_ current()返回进行中的线程
  • THREAD_READY
    • doubly LinkedList
  • THREAD_BLOCKED
    • 调用thread_unblock()进入THREAD_READY
  • THREAD_DYING

name

name

stack

  • uint8_t *
  • when the CPU switches to another thread,this member saves the thread’s stack pointer
  • When an interrupt occurs, whether in the kernel or a user program, an struct intr_ frame is pushed onto the stack

int priority

  • ranging from PRI_MIN (0) to PRI_MAX (63).

struct list_elem allelem

  • link the thread into the list of all threads

struct list_elem elem

  • put the thread into doubly linked lists, either readylist (the list of threads ready to run) or a list of threads waiting on a semaphore in sema down()

uint32_t * pagedir

unsigned magic

  • detect stack overflow
页阅读量:  ・  站访问量:  ・  站访客数: