Synchronization (computer science)
过程同步、数据同步。
In computer science, synchronization refers to one of two distinct but related concepts: synchronization of processes, and synchronization of data. Process synchronization refers to the idea that multiple processes are to join up or handshake at a certain point, in order to reach an agreement or commit to a certain sequence of action. Data synchronization refers to the idea of keeping multiple copies of a dataset in coherence with one another, or to maintain data integrity. Process synchronization primitives are commonly used to implement data synchronization.
The need for synchronization does not arise merely in multi-processor systems but for any kind of concurrent processes; even in single processor systems. Mentioned below are some of the main needs for synchronization:
Forks and Joins: When a job arrives at a fork point, it is split into N sub-jobs which are then serviced by n tasks. After being serviced, each sub-job waits until all other sub-jobs are done processing. Then, they are joined again and leave the system. Thus, in parallel programming, we require synchronization as all the parallel processes wait for several other processes to occur.
Producer-Consumer: In a producer-consumer relationship, the consumer process is dependent on the producer process till the necessary data has been produced.
Exclusive use resources: When multiple processes are dependent on a resource and they need to access it at the same time the operating system needs to ensure that only one processor accesses it at a given point in time.This reduces concurrency.
Classic problems of synchronization[edit]
The following are some classic problems of synchronization:
- The Producer–Consumer Problem (also called The Bounded Buffer Problem);
- The Readers–Writers Problem;
- The Dining Philosophers Problem.
These problems are used to test nearly every newly proposed synchronization scheme or primitive.
Synchronization in Linux[edit]
Linux provides:
- semaphores;
- spinlock;
- barriers
- mutex
- readers–writer locks, for the longer section of codes which are accessed very frequently but don't change very often.
- Read-copy-update (RCU) [12]
Enabling and disabling of kernel preemption replaced spinlocks on uniprocessor systems. Prior to kernel version 2.6, Linux disabled interrupt to implement short critical sections. Since version 2.6 and later, Linux is fully preemptive.
Synchronization in Solaris[edit]
Solaris provides:
- semaphores;
- condition variables;
- adaptive mutexes, binary semaphores that are implemented differently depending upon the conditions;
- readers–writer locks:
- turnstiles, queue of threads which are waiting on acquired lock.[13]
https://en.wikipedia.org/wiki/Synchronization_(computer_science)
最新文章
- 《C与指针》第十四章练习
- 爬虫5 html下载器 html_downloader.py
- LightOJ1298 One Theorem, One Year(DP + 欧拉函数性质)
- QT中QWS的含义 (转至 宋金时的专栏
- Postgres 9.4 feature highlight: REPLICA IDENTITY and logical replication
- 安装和配置JDK,并给出安装、配置JDK的步骤。
- JAVA必背面试题和项目面试通关要点
- (C#) What is the difference between ";const"; and ";static readonly"; ?
- 【剑指offer】面试题25:二叉树中和为某一值的路径
- SQL Server中的临时表和表变量
- poj 3273 Monthly Expense (二分搜索,最小化最大值)
- php薪资
- Pythagorean Triples
- bash脚本基础
- Redis环境搭建(MacOS)
- 2、jQuery的Ajax简单示例
- java项目部署常用linux命令
- 直接添加viewController中的view时的注意事项
- c#连接Redis Redis的安装与配置
- Python3中urllib使用介绍
热门文章
- 利用PBFunc在Powerbuilder中进行图片格式转换
- 杭电 2817 A sequence of numbers【快速幂取模】
- The German Collegiate Programming Contest 2017
- Day73-CMDB(资产管理采集)的三种实现方式
- jq——属性和方法
- thinkPHP利用ajax异步上传图片并显示、删除
- 决策树(Decision Trees)
- 论文阅读笔记“Attention-based Audio-Visual Fusion for Rubust Automatic Speech recognition”
- 论wpf的设备无关性 - 简书
- 旋转VR相机不头晕:一个反直觉的发现