Chinaunix首页 | 论坛 | 博客
  • 博客访问: 127143
  • 博文数量: 19
  • 博客积分: 508
  • 博客等级: 下士
  • 技术积分: 306
  • 用 户 组: 普通用户
  • 注册时间: 2009-03-11 21:04
文章分类

全部博文(19)

文章存档

2011年(16)

2009年(3)

我的朋友

分类: LINUX

2009-03-14 10:02:44

The following takes place between 02:00PM and 03:00PM

previously on 零基础学习Liunx:
    上一次写到init进程启动getty,getty启动通过login验证用户名以及密码,若正确,则启动shell。

4.当你从shell中运行某个program时,计算机在做什么?
    shell是用户与系统内核之间进行交互的接口,shell与内核是通过"系统调用"来实现通信的。这样做的好处是可以在不同的情况下使用不同的shell。
    在boot之后,计算机中有许多进程,它们等待相应的事件被触发。例如,网络数据包的到达。
内核就是这些进程之一。但是它是特殊的,因为它控制了其他的 用户进程,并且它是唯一可以直接访问硬件的进程。当用户进程需要访问这些硬件资源的时候,需要通过系统调用来实现。
基本上所有的I/O操作都要通过内核实现,因此内核便可以对这些操作进行调度。但有一些例外,比如X-SERVERS。
shell只是一个普通的用户进程。
举例:Let's say you type ‘ls’ and Enter to invoke the Unix directory lister. The shell applies its built-in rules to figure out that you want to run the executable command in the file /bin/ls. It makes a system call asking the kernel to start /bin/ls as a new child process and give it access to the screen and keyboard through the kernel. Then the shell goes to sleep, waiting for ls to finish.
When /bin/ls is done, it tells the kernel it's finished by issuing an exit system call. The kernel then wakes up the shell and tells it it can continue running. The shell issues another prompt and waits for another line of input.
译:假设我们现在使用'ls'命令来查看文件目录。shell通过系统调用告诉内核启动一个子进程'/bin/ls',并且让它能够访问屏幕和键盘。这时候,shell进程进入sleep状态,等待ls完成。
当ls完成以后,它通过exit系统调用通知内核。shell被唤醒。

5.中断工作的原理
    对于每个中断,都会有一个对应的中断处理器,是操作系统的一部分。
    每个中断都有相应的优先级,高优先级可以抢占低优先级中断。
    每个中断都有自己的IRQ numbers,当不同的设备试图使用相同的IRQ中断号时,便会出现错误。

6.计算机如何同时作许多事情?
    简单的说就是利用时分复用的机制,CPU快速切换各个任务。

Unix在设计之初就加入了多任务的概念,因此它在这方面相比起Windows以及Mac OS出色很多。

 

To be continued........

阅读(1463) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~