萍聚社区-德国热线-德国实用信息网

 找回密码
 注册

微信登录

微信扫一扫,快速登录

萍聚头条

查看: 854|回复: 2

请教linux内核高手

[复制链接]
发表于 2005-7-16 12:18 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册 微信登录

x
何为system context ? 何为interrupt context?他们的意义是什么呢?spinlocks是何解?它和semaphoore的区别又在何处?

希望大家不闵回答,说出一个也好,在此先谢过。
Die von den Nutzern eingestellten Information und Meinungen sind nicht eigene Informationen und Meinungen der DOLC GmbH.
发表于 2005-7-19 15:44 | 显示全部楼层
原帖由 corba 于 2005-7-16 13:18 发表
何为system context ? 何为interrupt context?他们的意义是什么呢?spinlocks是何解?它和semaphoore的区别又在何处?

希望大家不闵回答,说出一个也好,在此先谢过。


http://www.cis.temple.edu/~ingargio/cis307/readings/spinsem.html

Spinlocks are abstract data types, or classes, that support a Busy-Wait solution for the Mutual Exclusion Problem。

People use the term "Semaphore" to refer to a variety of synchronization mechanisms. Here by "Semaphore" we mean the "non-busy-waiting" analog of SpinLocks.

*Spinlocks implement a "busy wait condition" for a resource. If a processor attempts to obtain a spinlock being held by another processor, it will wait until the lock is released.

      Spinlocks can be acquired on an interrupt stack. A deadlock can arise, however, if a processor takes an interrupt while holding a spinlock and the interrupt code tries to acquire the same spinlock. To prevent this from occurring, HP-UX requires the spl level to be raised whenever a spinlock is acquired. When the spinlock is released, the prior spl level is reverted to. Once a spinlock is acquired, the spl level should not be lowered within the spinlocked critical section.

      Spinlocks are used to synchronize access to data between multiple processors, and as such, have little value in a uniprocessor system. Within the kernel the MP_SPINLOCK() macro checks the uniprocessor flag and returns if not an MP system.



* Kernel semaphores control access through blocking strategies. With blocking semaphores, a processor attempting to acquire a semaphore already held by another processor will put its current thread to sleep and context switch to another task.

      Semaphores are used to provide mutual exclusion or to synchronize access between multiple processes or threads, regardless of how many processors there are.

[ 本帖最后由 asdfgh 于 2005-7-19 16:46 编辑 ]
Die von den Nutzern eingestellten Information und Meinungen sind nicht eigene Informationen und Meinungen der DOLC GmbH.
 楼主| 发表于 2005-7-19 17:46 | 显示全部楼层
唉,多谢asdfgh兄弟了,可惜内核考试今天已经考完了。关于这个,偶也从网上找了些资料,可是没有你的英文介绍那么全。

说说偶的理解,spin lock 和 semaphore都是kern用来synchronisation的operation,主要区别是应用的区域,spin lock 用在短期,semaphore用在长期,另外spin lock 是原子操作,semaphore不能用于中断处理。

上面的两个则是kern用来存储临时信息的区域,一个对进程,一个对中断,具体意义就是在任务切换的时候,能够保留当前运行信息,然后回头还能继续完成。
Die von den Nutzern eingestellten Information und Meinungen sind nicht eigene Informationen und Meinungen der DOLC GmbH.
您需要登录后才可以回帖 登录 | 注册 微信登录

本版积分规则

手机版|Archiver|AGB|Impressum|Datenschutzerklärung|萍聚社区-德国热线-德国实用信息网

GMT+1, 2025-2-7 09:52 , Processed in 0.072644 second(s), 21 queries , MemCached On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表