Can multithreading be applied at the shared level at the OS or programming language level? (OSX, Objective-C)

I am trying to implement the concurrency acting model in Objective-C because I want to avoid the infamous problems of shared state change, locks, semaphores, etc. This can be done, but it requires real discipline to avoid the accidental use of the general condition.

One way to enforce the shared-nothing rule is to use separate processes instead of separate threads, but I think this is redundant and will have unpleasant overheads. What I really like is that it reaches the same end, but easier. Is there anything that matches this description?

+3
source share
4 answers

The short answer to your question, unfortunately, reads: "There are no OS tools that can provide sharing of any lighter weight than the process." Theoretically, this would be an interesting direction for a static analysis tool (for example, clang), but today I do not know about such a tool.

However, did you carefully examine Grand Central Dispatch (aka libdispatch) and block it?

, GCD , shared-nothing concurrency. , " NSOperation, ..", , . , API- , NSBlockOperation/NSOperationQueue, API- libdispatch.

+1

ActorKit

-, . .

+1
0

A good approach for you is messaging. Two participants or threads connect a communication channel between them. The semantics of this channel can be complex or simple. The simple semantics is that messages are atomized and atomized. This can be used to implement an approach without shared access and is the method of choice for many programming models.

This model is used by the Google GO language.

0
source

Source: https://habr.com/ru/post/1755928/


All Articles