Creating a thread VS Forking a thread
来源:互联网 发布:苹果移动数据怎么快捷 编辑:程序博客网 时间:2024/05/01 05:27
Thread *t;
char id[2], *name = "t";
int i, NumThreads = 4;
for(i=0;i<NumThreads;i++) {
sprintf(id,i);
strcat(name,id);
t = new Thread(name);
}
•creates 4 threads using the constructor function for the class Thread
•The constructor function simply allocates space for thread and sets its status to JUST_CREATED
•in Nachos, a "main" thread is created as part of system initialization
•the ready list remains empty upon creation of these threads.
•the global variable currentThread always points to the thread currently occupying the CPU
fork:
Thread *t;
char id[2], *name = "t";
int i, NumThreads = 4;
for(i=0;i<NumThreads;i++) {
sprintf(id,i);
strcat(name,id);
t = new Thread(name);
t->Fork("somefunction",0);
}
•Fork() allocates a stack for the thread which invokes it, and adds it to the ready list maintained by the scheduler
•StackAllocate() allocates and initializes the execution stack for the thread.
•A C routine ThreadRoot() is called which calls the function "somefunction" and upon its return, calls ThreadFinish().
•now, we have all four threads in the ready list with their status set to READY. currentThread still points to "main".
- Creating a thread VS Forking a thread
- Java Thread Programming 1.3 - Creating and Starting a Thread
- AfxBeginThread usage for creating a Mfc Worker Thread
- Interrupting a thread
- Create a thread demo
- Create A Thread
- A Thread's Message Queue
- Love is just a thread
- How to Stop a Thread
- Create a thread under linux
- Suspending and Resuming a Thread
- 1075 Thread in a space
- 【代码积累】join a thread
- When a QThread isn't a thread...
- Java Thread Programming 1.2 - A Simple Two-Thread Example
- Thread local to save a variable for each Thread
- IllegalThreadStateException: Thread already started on a new Thread
- Main Thread Checker: UI API called on a background thread:
- 用 Photoshop 计算命令优化美女照片皮肤
- C#中接口的显式和隐式实现
- Javascript设计模式:事件设计模式
- 烁空(SOCUT.COM)开发的网络课堂系统的破解(socut.data.dll)
- ASP.NET 程序中常用的三十三种代码
- Creating a thread VS Forking a thread
- 用 Photoshop 清晰还原人物模糊照片
- blog心情
- 阈值分割法简述 - ywywcy的专栏 - CSDNBlog
- Visual C++ 实现Kirsch算子 - 图像处理 - appig
- 图像二值化阀值(Kirsch算子) - ywywcy的专栏 - CSDNBlog
- 关于C#中timer类 在C#里关于定时器类就有3个
- LINUX 常用命令集合
- 边缘检测类(包括Roberts, Sobel, Prewitt, Kirsch等算子的边缘检测算法) - wtuyzh的专栏 - CSDNBlog