Is SCIP safe to call from multiple threads? - scip

We need to solve many different instances of a problem, where each problem is completely separate from the others. Is SCIP (SCIPsolve) safe to call from multiple threads this way?
I did find some information on SCIPsolveParallel, but this appears to be about working on the same problem using multiple threads. There is also SCIPsolveConcurrent, but there is little information on what it is for.

this is not a problem.
There exists a build flag THREADSAFE that you can make sure is enabled (though it is on by default).

Related

WebFlux locks. How?

I usually write imperative code on Java/Spring MVC, but now my team implement project on WebFlux. I tried to research the topic, but I can't find the answer to the question about locks.
It's normal when we have code that should always be executed by only one thread, or that has locks by some condition (for example, the code should not be executed concurrently for the same entity). These locks can be distributed, for example, through a Redis.
But how is this problem solved in Project Reactor? As far as I understand, it would be a bad idea to use a synchronized block, or ReentrantLock, because they will block threads while we avoid blocking.
It turns out that we need to design the application in such a way that there is no need for locks. Which is not always possible.
Or is there any solution? I will be grateful for any information.
There is no official implementation, here are some resources for reference.
How to trigger Mono execution after another Mono terminates
https://github.com/chenggangpro/reactive-lock

Whatefficient a simple way to lock access to specific resource in kotlin

We received an assignment where we have to create a distributed file system. This file-system should have multiple servers, each performing a certain function.
This question relates to the lock-server, which is used to prevent two people from writing to the same file at once. Every attempt to access a file generates a thread, that when finished provides access to the requested file. If a file that is not currently free is accessed, the thread should be BLOCKED until the lock is released. With JAVA I would probably just use the wait() and notify() methods, but these are not present in Kotlin (I know you can force them in by casting but it is frowned upon). Is there an elegant way to do this? We are not limited in what libraries we can use so if you know one that could fit I will gladly check it out. Right now the one I think would fit the most is the ReentrantLock, but I am looking for more possibilities.
I have also checked out this list: https://stackoverflow.com/a/35521983/7091281
But none of the ones listed seemed to fit - I specifically need to block the thread, while everything I find does the exact opposite.
BTW the different parts of the system are supposed to communicate via RMI. Also while we can go our own way, it is encouraged to use threads instead of coroutines. (we are supposed to work in JAVA but we were allowed to use kotlin and scala)
If you want to use pure Kotlin, you could leverage coroutines, and more specifically its Mutex for locking.
More info can be found at the Kotlin docs, regarding Shared Mutable State and Concurrency

Is it possible to introduce multi threading in dotnet without explicity creating new threads?

I have a loop of several hundred items which need to be processed.
Each item is processed by conditionally setting a global SQLConnection where upon the item is processed using this SQLConnection as part of the processing.
For this reason it is vital that none of these items is allowed to be processed in parallel.
I appreciate that this is not good design and I hope to rectify it as soon as is practical.
However it would seem that despite my best efforts, this code is experiencing some form of multi-threading. Somehow one of these tasks has thrown an exception.
This exception is the violation of a foreign key constraint, but indicates that it was operating against a SQLConnection which it has no business connecting to.
Naturally I have concerns about this, however to my knowledge there is no multi threading code in this app.
I wonder Is it possible to introduce multi threading without explicitly creating new threads
EDIT:
VB.Net 3.5SP1
Console App + Class Libraries
Occasionally Calls out to web services
Makes SQL calls
not much of anything else. No Winforms, no WPF.
Yes - using System.Timers.Timer and/or System.Threading.Timer can cause the effect your describing. Whenever a timer ticks a new work item is queued in the ThreadPool - so essentially you have a multi threading program without explicitly creating new threads.
If the timer is AutoReset (remains enabled after elapsed has been called) you might cause another call to the same handler concurrently.
In addition to the others that have been mentioned: parallel extensions (PLINQ and task parallel library).
Alternatively tasks (ie Task objects) are not called threads, but are. Tasks are commonly found near lambda expressions, check if you have any.
Oh, and async sockets too and all the other async IOs.
BUT:
Instead of trying to avoid multithreading at all cost, wouldn't it be easier to lock ? Sorry if the question is naive, I may miss something.
Could it be that your code is called from a 3rd party library. By using events another library can call your code - from as many threads as it like.
I suggest you check the code that invoke the code that changes and make sure that there's no suspicious calls to your code.

How to create an atomic function in objective-c

Is there a way to execute a whole objective-c function atomic?
As far as I know, using synchronized only protects a specific peace of code from being executed on multiple threads at the same time. But what I want is stop ALL other threads from doing ANYTHING, as long as I execute the function.
There is a wealth of info in the Threading Programming Guide. It specifically mentions to avoid synchronization (which is funny, cause you cant sometimes) but they offer some suggestions around the problem.
You will have serious problems with your design if you start running your software on multicore. It is a VERY expensive operation to stop all cores from running to run your bit of code. Mutexes, semaphores, run loop events, and atomic operations are the way to go.
Nope. Can't do that.
Or, well, you probably could if you dipped deep enough in the Mach APIs (on Mac OS X anyway).
But you shouldn't do that.
Why do you think you want to do that?

Single or multiple process, what criteria decides it?

In embedded systems using linux for an application; under which condition will you divide an application into two/three processes. My main doubt is; is it required to divide a single application component into multiple processes and then run multiple processes to achieve the required application functionality.
By experience I tend to isolate possibly problematic pieces of code. For example if you're depending on a sensor which ships with 3rd party libraries that you do not trust, making it a separate process will make your application more robust and fault-tolerant because you'll be (hopefully) able to restarts only parts of it.
Also for integration purposes it might be easier. Suppose your process A runs fine, then you can plug in the process B easily instead of adding new parts to process A. It might not seem like a big plus right now but it depends a lot on your project.
It does come with some overhead however, as dealing with synchronization and message passing can be more complicated and add to the design.
You don't have to do anything like that however.
You don't tell much about the circumstances that led you to your question, so I can only guess what kind of answer you are interested in.
Linux offers multi-threading functionality since ages, so concurrent programming can be done without multiple processes.
There is rarely a functional reason to divide integral components of an application into processes.
My suggestion is to write a single-process application. Should the requirement arise, that is: a problem can only be solved by managing runtime resources in separate processes, you can still take on the heavy work of solving inter-process communication and resource sharing, without having to change much in your business logic.