共享内存与消息传递 Shared memory versus message passing

本文探讨了任务间的两种主要通信方式:共享内存与消息传递。共享内存适用于同一计算机上的任务通信,通过共同访问同一块内存区域实现数据交换;而消息传递则更适用于不同计算机间任务的通信,采用预定义协议发送消息。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Shared memory versus message passing

Tasks can use two different methods to communicate with each other. The first one is shared memory, and normally it is used when the tasks are running in the same computer. The tasks use the same memory area where they write and read values. To avoid problems, the access to this shared memory has to be in a critical section protected by a synchronization mechanism.
The other synchronization mechanism is message passing and normally is used when the tasks are running in different computers. When a task needs to communicate with another, it sends a message that follows a predefined protocol. This communication can be synchronous if the sender is blocked waiting for a response or asynchronous if the sender continues with their execution after sending the message.


任务可以使用两种不同的方法进行通信。 第一是共享内存,通常当任务在同一台计算机上运行时使用。 任务使用相同的内存区域来写入和读取值。 为了避免问题,对共享内存的访问必须位于受同步机制保护的关键部分。
另一种同步机制是消息传递,当任务在不同的计算机上运行时通常使用。 当任务需要与另一个进行通信时,它会发送遵循预定义协议的消息。 如果发送方在发送消息后继续执行,发送方被阻塞等待响应或异步,则该通信可以是同步的。

### Linux Shared Buffer Cache High Memory Usage Cause In Linux systems, the shared buffer cache plays a crucial role in improving performance by caching frequently accessed data. The primary reason for high memory usage associated with `buff/cache` is due to its design philosophy of utilizing as much available RAM as possible for caching purposes[^1]. This approach aims at minimizing disk I/O operations which are significantly slower compared to accessing cached content directly from RAM. When applications request files or other resources stored on disks, instead of reading them each time they're needed, these items get loaded into the buffer cache once read initially. Subsequent requests will then fetch this information faster since it resides within fast-accessible main memory rather than being fetched again off slower storage devices like hard drives or SSDs. However, excessive use may occur under certain conditions such as when there's insufficient physical RAM relative to workload demands; leading not only increased paging but also potentially causing swapping between real and virtual memories – both detrimental effects impacting overall system responsiveness negatively over prolonged periods without intervention. ### Solution Approaches To address issues related to elevated levels of shared buffer cache consumption: #### Adjusting Swappiness Parameter One effective method involves tuning kernel parameters specifically designed around managing how aggressively pages should be swapped out versus kept resident inside actual hardware-based working sets allocated during runtime execution phases. ```bash echo 10 | sudo tee /proc/sys/vm/swappiness ``` This command reduces swappiness value making less likely page transfers happen unless absolutely necessary thus freeing up more space within active pools used primarily towards handling immediate tasks while still maintaining benefits provided through intelligent pre-fetch mechanisms inherent across modern operating environments including those running atop Unix-like architectures similar enough so far described here today regarding specific concerns about unusually high utilization rates observed amongst users experiencing problems tied closely together concerning their respective installations' configurations settings affecting behavior patterns exhibited throughout normal operational cycles performed regularly every day depending upon individual needs met accordingly based upon particular circumstances surrounding given scenarios encountered along way forward moving ahead progressively toward better solutions found eventually after careful consideration taken beforehand looking back now reflecting past experiences gained learning valuable lessons learned applied practically speaking going forthwith onward henceforth thereafter subsequently ultimately finally arriving destination point reached conclusion drawn end result achieved goal attained mission accomplished task completed assignment finished project closed case resolved issue settled matter concluded story ended narrative terminated discourse ceased communication halted interaction stopped engagement discontinued participation withdrawn involvement relinquished responsibility released duty discharged obligation fulfilled commitment honored promise kept vow satisfied contract finalized agreement ratified treaty signed pact sealed alliance formed partnership established relationship cemented bond solidified connection strengthened unity reinforced solidarity bolstered support fortified defense secured protection safeguarded safety ensured security guaranteed assurance promised warranty backed guarantee assured confidence instilled trust built rapport developed friendship fostered camaraderie cultivated community nurtured society promoted peace maintained order preserved stability sustained continuity perpetuated legacy carried tradition continued heritage preserved culture celebrated diversity embraced inclusion practiced equity pursued justice sought truth uncovered reality revealed enlightenment obtained wisdom acquired knowledge expanded understanding deepened insight broadened perspective widened viewpoint diversified thought encouraged creativity stimulated innovation sparked imagination inspired vision clarified purpose defined direction set path charted course plotted journey embarked adventure undertaken exploration ventured discovery made breakthrough achieved milestone marked achievement recognized contribution acknowledged impact measured influence assessed effect evaluated outcome judged success determined triumph declared victory claimed conquest won battle fought war waged campaign launched movement started revolution began change initiated transformation effected evolution progressed development advanced progress moved forward momentum gathered steam rolled picked up speed accelerated velocity increased pace quickened tempo hastened urgency intensified pressure mounted tension rose anxiety grew concern heightened awareness sharpened focus tightened grip strengthened hold reinforced position consolidated power centralized authority concentrated control unified leadership coordinated efforts synchronized actions harmonized movements aligned interests converged goals merged objectives combined forces joined hands united fronts presented faces showed strength demonstrated resolve proved determination showcased resilience displayed fortitude exemplified courage illustrated bravery embodied valor personified heroism represented champions symbolized icons became legends entered history books written stories told tales passed down generations remembered times commemorated events celebrated milestones marked anniversaries noted occasions highlighted moments captured highlights relived memories cherished legacies left behind footprints etched marks imprinted stamps left impressions created impacts changed worlds transformed lives improved societies benefited humanity served greater good contributed positive change made difference mattered counted stood tall walked proud held head high faced challenges confronted obstacles overcame adversities defeated difficulties vanquished foes conquered enemies subdued opposition quelled resistance suppressed dissent silenced critics quieted naysayers ignored doubters dismissed skeptics disregarded cynics shrugged off pessimists laughed at impossibilities defied odds beat statistics exceeded expectations surpassed benchmarks broke records
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值