r******s 发帖数: 925 | 1 【 以下文字转载自 robotics 讨论区 】
发信人: robotics (机器人技术), 信区: robotics
标 题: 实时进程间通讯问题
发信站: BBS 未名空间站 (Tue Jun 24 23:45:44 2008), 转信
两个不同的real time进程运行在不同的CPU上面,使用一段共享内存进行同步
内存容量足够大,我想采用的方法,就是划分块
A块属于A进程写,B只读的区域,
B块属于B进程写,A只读的区域。
由于没有使用中断,两边都是在固定的时钟周期内写自己的区域同时读对方的区域
这样编程比较简单,我想了解一下可能出现的后果,
比如,A读了B正在写的区域
那么我可以为每个块设置一个标志位,代表在写,在读,或者ready
有没有哪位大侠给出一个简单但是确保安全的办法? | s******e 发帖数: 431 | 2 如果不用任何lock的话,我觉得一个标志位可能不够,需要多个,比如要写,正在写,
写完。一点想法。 | a****l 发帖数: 8211 | 3 I think that is basically a "lock" problem, and ususally it is not trivial
without any hardware support. On the other hand, you may consider some
operations will not be interrupted, e.g. , read/write to one bit. So,
starting from there, you can have something. E.g., one says "intend to write
", one follows "acknowledge to write", then one writes.
【在 r******s 的大作中提到】 : 【 以下文字转载自 robotics 讨论区 】 : 发信人: robotics (机器人技术), 信区: robotics : 标 题: 实时进程间通讯问题 : 发信站: BBS 未名空间站 (Tue Jun 24 23:45:44 2008), 转信 : 两个不同的real time进程运行在不同的CPU上面,使用一段共享内存进行同步 : 内存容量足够大,我想采用的方法,就是划分块 : A块属于A进程写,B只读的区域, : B块属于B进程写,A只读的区域。 : 由于没有使用中断,两边都是在固定的时钟周期内写自己的区域同时读对方的区域 : 这样编程比较简单,我想了解一下可能出现的后果,
| p***o 发帖数: 1252 | 4 Just FYI, for concurrency without ANY hardware support, Lamport's
bakery algorithm could be used ...
research.microsoft.com/users/lamport/pubs/pubs.html#bakery
Cited from the page:
"Before the bakery algorithm, people believed that the mutual exclusion prob
lem was unsolvable--that you could implement mutual exclusion only by using
lower-level mutual exclusion. Brinch Hansen said exactly this in a 1972 pap
er. Many people apparently still believe it. (See [90].) "
write
【在 a****l 的大作中提到】 : I think that is basically a "lock" problem, and ususally it is not trivial : without any hardware support. On the other hand, you may consider some : operations will not be interrupted, e.g. , read/write to one bit. So, : starting from there, you can have something. E.g., one says "intend to write : ", one follows "acknowledge to write", then one writes.
| m*****e 发帖数: 4193 | 5 Which CPU?
【在 r******s 的大作中提到】 : 【 以下文字转载自 robotics 讨论区 】 : 发信人: robotics (机器人技术), 信区: robotics : 标 题: 实时进程间通讯问题 : 发信站: BBS 未名空间站 (Tue Jun 24 23:45:44 2008), 转信 : 两个不同的real time进程运行在不同的CPU上面,使用一段共享内存进行同步 : 内存容量足够大,我想采用的方法,就是划分块 : A块属于A进程写,B只读的区域, : B块属于B进程写,A只读的区域。 : 由于没有使用中断,两边都是在固定的时钟周期内写自己的区域同时读对方的区域 : 这样编程比较简单,我想了解一下可能出现的后果,
| r******s 发帖数: 925 | 6 Good reference, Thanks a lot!
prob
using
pap
trivial
【在 p***o 的大作中提到】 : Just FYI, for concurrency without ANY hardware support, Lamport's : bakery algorithm could be used ... : research.microsoft.com/users/lamport/pubs/pubs.html#bakery : Cited from the page: : "Before the bakery algorithm, people believed that the mutual exclusion prob : lem was unsolvable--that you could implement mutual exclusion only by using : lower-level mutual exclusion. Brinch Hansen said exactly this in a 1972 pap : er. Many people apparently still believe it. (See [90].) " : : write
| j**********p 发帖数: 22 | 7 seqlock
【在 r******s 的大作中提到】 : Good reference, Thanks a lot! : : prob : using : pap : trivial
| l*****g 发帖数: 547 | 8 If you are using *NIX systems, POSIX IPC can give you sufficient supports:
Solution 1: message queue. but you will need thread support if two processes
running on different cycle times.
solution 2: semaphore + shares memory, but you need to make sure there is
no deadlock.
I am not sure how to do it on windows.
【在 r******s 的大作中提到】 : 【 以下文字转载自 robotics 讨论区 】 : 发信人: robotics (机器人技术), 信区: robotics : 标 题: 实时进程间通讯问题 : 发信站: BBS 未名空间站 (Tue Jun 24 23:45:44 2008), 转信 : 两个不同的real time进程运行在不同的CPU上面,使用一段共享内存进行同步 : 内存容量足够大,我想采用的方法,就是划分块 : A块属于A进程写,B只读的区域, : B块属于B进程写,A只读的区域。 : 由于没有使用中断,两边都是在固定的时钟周期内写自己的区域同时读对方的区域 : 这样编程比较简单,我想了解一下可能出现的后果,
|
|