shitou's blog 
Home About Feed | MIX BOY 塌客

Tags "进程"

06
Aug

进程和线程 by shitou

0

最近在看ruby的线程这块的东西,就找了些资料关于linux进程和线程的,因为ruby的线程是基于linux和unix的,所以机制也和linux一样,

Introduction to threads and processes
进程和线程简介
Programs consist of a number of processes, each of which contains one or more conceptually concurrent threads of execution.
程式包含了若干进程,每一个进程包含了一个或多个概念上知执行的线程。
A thread is the unit of execution within a process. Every time a process is initialised, a primary thread is created. For many applications the primary thread is the only one that the application requires; however, processes can create additional threads.
线程是进程的执行单元。当进程被初始化后,主线程就被创建了。对于绝大多数的应用程式来说,通常仅需要有一个主线程。尽管如此进程也能够创建额外的线程。
Each user process has its own private address space, i.e. a collection of memory regions which that process can access. A user process cannot directly address memory areas in the address space of another process. There is also a special process, the Kernel process, whose threads run at supervisor privilege level. This process normally contains two threads:
每一个用户进程拥有自己私有的地址空间,也就是说,进程拥有一定的可被其访问的内存区域。一个用户进程不能够直接访问其他进程的地址空间。另外更有一个特别的进程,内核进程,他运行在终极用户权限模式。这个进程通常包括两个线程:
the Kernel server thread, which is the initial thread whose execution begins at the reset vector, and which is used to implement all Kernel functions requiring allocation or deallocation on the Kernel heap. This is the highest priority thread in the system.
Kernel server (内核服务器)线程:是个初始的进程,在系统启动时就已存在。他能够在heap执行由核心函数请求的内存分配或内存的重分配。这是系统中具备最高权限的线程。
the null thread, which runs only when no other threads are ready to run. The null thread places the processor into idle mode to save power.
null (空)线程:当系统中没有其他可运行的线程时这个线程就开始运行,null 线程使处理器处于空闲状态,减少耗电。
Threads execute individually and are unaware of other threads in a process. The scheduling of threads is pre-emptive, i.e. a currently executing thread may be suspended at any time to allow another thread to run.
线程是单独运行的,他且并不知道进程中更有其他线程存在。线程的执行是抢占式的,也就是说,当前运行的线程在任何时候都可能被挂起,以便另外一个线程能够运行。
Each thread is assigned a priority; at any time, the thread running is the highest priority thread which is ready to run. Threads with equal priority are time-sliced on a round-robin basis. Context switching between threads involves saving and restoring the state of threads. This state includes not only the processor registers (the thread context) but also the address space accessible to the thread (the process context). The process context only needs switching if a reschedule is between threads in different processes.
每一个线程都配置了优先限权;在 任何时候,只要线程已准备就绪,具备高优先权的线程总是首先运行。假如线程具备相同的悠闲权,则根据时间片进行轮转调度。上下文的转换包括了保存和恢复线 程状态。这个状态不但仅包含了处理器寄存器(进程上下文)而且还包含了线程可访问的地址空间(进程上下文)。只有在重新调度是在两个进程间进行的时候,进 程上下文才被转换。
Compare this with active objects which allow non pre-emptive multi-tasking within a single thread.
把这个和活动对象比较,活动对象允许在一个线程中实现非强占式的多任务调度。
A thread can suspend, resume, panic and kill another thread.
一个线程能够被挂起,唤醒、异常抛出和结束其他线程。
When a thread is created it is put into a suspended state, it does not begin to run until that thread’s Resume() member function is called.
线程被创建以后,他处于挂起状态。他没有马上进入运行状态,直到他的Resume()成员函数被调用。
When a thread is created, it is given the priority EPriorityNormal by default. The fact that a thread is initially put into a suspended state means that the thread priority can be changed (RThread::SetPriority()) before the thread is started (RThread::Resume()).
线程创建以后,他具备EPriorityNormal的默认优选级。线程被初始化并处于挂起状态,这意味着在线程开始运行前,线程的运行优先级能够被改变(通过调用RThread::SetPriority())


就是线程被创建的时候默认是没有运行的,即处于挂起(suspend)状态,所以要进行唤醒(wakeup,或者是join)才能运行,在唤醒前可以调整线程的优先级

Tags: 线程,进程,ruby

2008-08-06 09:43:03, 443 reviews

send to mailbox

Your email:

Tags

U-ka saegusa IN db command Mai Kuraki Norah Jones log iPhoneException ACG Mac Safari objective-c CouchDB LVS AJAX debian 推荐 AMQP google mail bug gettext Erlang 北京 iptables 架构 tips mysql backup function 我看 postfix 监控 SEO cache Etag memcache thread 进程 线程 无锡 yield file column mixboy xml rss gems ruby shitou shell lighttpd 安全 csrf 公司 nginx linux 模块 apache webserver 朋友 大学 生活 尼古拉斯凯奇 movie 文件同步 笑笑 歌词 auto complete plugin rails music ubuntu blog

Category

  • iPhone[17]
  • Erlang[4]
  • google[8]
  • 生活[38]
  • 音乐[11]
  • 电影[11]
  • linux[20]
  • web server[6]
  • mail server[3]
  • cluster[1]
  • system manage[5]
  • ruby[18]
  • ruby on rails[27]
  • 开源[3]

Episode

  • iPhoneException
  • shell
  • thread
  • memcache

Recent Comments

  • comment6, viagra bez receptu, revelation, ambie...
  • comment5, http://www.freecodesource.com/user/pr...
  • comment4, meridia medicine, :-<>], plavix clopi...
  • comment2, viagra calgary, resin, paxil vs wellb...
  • comment2, codeine promethazine, conclusion, buy...
  • comment2, clomid ovarian cysts, fronted, oxycod...
  • comment2, http://www.freecodesource.com/user/pr...
  • comment3, cipro allergy, :-E, weed and hydrocod...
  • comment2, http://www.freecodesource.com/user/pr...
  • comment4, vicodin cr, chocolate, premarin cance...

Popular Posts

  • MySQL Innodb备份
  • 准备开始学习Erlang了(恶狼, 二郎..)
  • Lighttpd配置参数
  • iPhone上的HelloWorld终于跑起来了
  • Etag和Expire

Recommended Posts

  • Mai Kuraki -永远より ながく
  • U-ka saegusa IN db Final Best
  • Heaven Can Wait - Charlotte Gainsbou
  • Ruby遍历MemCached的key
  • Norah Jones - The fall
  • 请记得仰望梦想的姿势
  • Shell: 统计MySQL InnoDB表的大小
  • Rails Benchmark
  • 发送异常到邮箱
  • I Miss Nobody
  • Music4u, Vol. 1
  • my macbook
  • Mai Kuraki-Beautiful
  • 10首最伤情英文歌曲精选
  • Mai Kuraki - PUZZLE/Revive

Friends' blogs

  • levy
  • sphance
  • andreas

Login

   注册

留言 查看留言

留言

   取消

留言 查看留言


Statistics

  • 访问次数: 51144
  • 今天访问: 8
  • 日志: 172
  • 评论: 124
  • 音乐: 9
  • 用户: 148


 

just DO NOT support IE

close