摘要: http://oss.org.cn/kernel-book/ch13/13.6.1.htminit进程的建立Linux将要建立的第一个进程是init进程,建立该进程是以调用kernel_thread(init,NULL,0)这个函数的形式进行的。init进程是很特殊的——它是Linux的第一个进程,也是其它所有进程的父进程。让我们来看一下它是怎样产生的。在调用kernel_thread(init,NULL,0)函数时,会调用main.c中的另外一个函数——init()。请注意init()函数和init进程是不同的概念。通过执行inin()函数,系统完成了下述的工作:·建立dbflus 阅读全文
posted @ 2013-09-19 23:45 hailong 阅读(778) 评论(0) 推荐(0)
摘要: 按照书上码了下,但运行有问题,暂时不知道原因:function send (x) coroutine.yield(x)endfunction producer() return coroutine.create( function () while true do local x = 1 send(x) end end)endfunction receive(prod) local status, value = coroutine.resume(prod) return valueendfunction filter (prod) return coroutine.creat... 阅读全文
posted @ 2013-09-19 15:33 hailong 阅读(257) 评论(0) 推荐(0)
摘要: 迭代器并没有真正的迭代,真正迭代的是for循环。而迭代器为每次迭代提供成功后的返回值。function allwords(f)for line in io.lines do for word in string.gmatch(line,"%w+") do f(word) end endend一个迭代器接受函数为参数,就完成了真正的迭代功能了。好强大! 阅读全文
posted @ 2013-09-19 09:09 hailong 阅读(162) 评论(0) 推荐(0)