系统相关
首页 > 系统相关> > Linux concurrency - 1.简介

Linux concurrency - 1.简介

作者:互联网

kernel本身就是个multithread concurrent的系统。在没有适当条件保证下,存取共享资源很容易发生race condition.共享资源包括周边IO及共享奶给你的数据结构等。可通过适当的synchronization机制提供critical section来保证资源的存取。个人认为kernel里面与concurrency相关的机制大致分为以下几类:

1.architecture support

2.busy-waiting lock:CPU loop等待直到取得lock.critical section中不允许睡眠。通常用来SMP下保证资料数据结构。有以下几种:

3.lock-free synchronization:通过区分reader与writer的角色以及deffered destruciton来减少lock使用

4.blocking synchronization:如果没有拿到lock会进入睡眠。通常用来保证较大的critical section与存取IO相关的机制。可分为以下几种:

标签:synchronization,Linux,lock,section,writer,reader,critical,concurrency,简介
来源: https://www.cnblogs.com/ellabrain/p/15836728.html