Questions tagged [multithreading]

Multi-threading related questions including technique, structure, and safety issues.

Filter by
Sorted by
Tagged with
0
votes
0answers
45 views

How can you multithread an html parser [ in C++ and similar languages ]?

Ive done two HTML parsers. Done with Regular Expressions [that accounted for nesting]. It was quick, but error prone. Done by evaluating Character by Character through switches. Here was the basic ...
0
votes
0answers
12 views

Using coroutines dispatchers as executor

We can use coroutines dispatchers as executor like Dispatchers.Default.asExecutor() and we do it when we want to use a coroutine just as a executor for operations in application lifetime like ...
0
votes
0answers
36 views

Creating a microservice REST api to offload CPU intensive tasks from node.js

I am building a game which has rooms with clients connected. Each room has it's own websocket. At the end of the game, some calculation needs to be made about who won and it's a complicated math CPU ...
-4
votes
0answers
19 views

Question Regarding the blocking/non-blocking nature of external HTTP requests using SpringBoot andRestTemplate

I have a question regarding making external requests using RestTemplate. I have a micro-service written using Spring Boot that based on an incoming user request, will in turn execute a http request ...
1
vote
1answer
65 views

How to represent this multithread application?

I am having trouble trying to represent some multithread process and I would appreciate some advice. Please let me explain this with code. (in C++'ish because that is what I am familiar but ...
0
votes
0answers
31 views

GoLang concurrency model - Using context

I learnt that, the reason we have context(P) introduced in Goruntime, is that we can hand them off(it's LRQ of goroutines) to other OS thread(say M0), if the running OS thread(M1) needs to block for ...
-3
votes
2answers
131 views

Generating unique numeric ids in multiple thread application without locking

Multi Threaded application with n threads implemented using ExecutorService. There are x (tens of millions) tasks submitted to the ExecutorService. Each task needs to generate millions (number of ...
-1
votes
1answer
94 views

Do other languages have variables shared between threads?

I guess it would be too complex for Node.js / JavaScript to leverage, but I've been working with clusters in node to break big tasks down so all cores can work at once but the inter-process messaging ...
0
votes
0answers
15 views

Porting a SYSV IPC multiprocess architecture to Windows

I'm looking at porting a Unix-based multi-process architecture server application. The app uses SYS V IPC shared memory and semaphores. It has a main message queue in shared memory, with semaphores ...
-2
votes
1answer
47 views

How can I represent with UML a process that involves queues?

I would like to use UML diagrams to show some processes I am designing and would like to implement. The processes involve using a queue, and adding and taking out elements from it. In one of this ...
0
votes
2answers
55 views

Which UML diagram is more adequate to represent a multithread process with loops

I have a process that I have been able to drawn somehow with a flowchart. This process involves several classes, loops and several threads of execution. However I am unsure which (if any) UML ...
-3
votes
1answer
64 views

Methods for reliably benchmarking own program's run time

I'm writing a basic password cracker in C as an introduction to multithreaded programming. I've implemented this already using a 'parallelization' approach that spins up a set number of threads and ...
2
votes
3answers
107 views

Should services in a service layer be thread safe?

This is for an Android app, but I think the question applies to any software designed with a service layer. Our app is structured with a presentation layer that handles the UI and a service layer ...
3
votes
3answers
150 views

How can I improve the speed of scanning multiple directories recursively at the same?

So I am trying to speed up my program by using concurrency and/or multi-threading and/or process parallelism. The topics are pretty complex and I am sort of new to them so I am still trying to figure ...
1
vote
1answer
58 views

Handling background tasks that may not be relevant when they are completed

Imagine the following pattern: you have a window with information that needs to be updated asynchronously. You launch and detach a thread to handle fetching the information, but while the information ...
1
vote
1answer
58 views

Long running REST API in PHP, async?

I have a RESTful API built with PHP. In POST request saving to DB is triggered. The problem is that now I have to support long running tasks. For example a user triggers POST request that is going to ...
0
votes
0answers
23 views

How to design data persistence in an application which stores data-streams from multiple clients

I'm developing a data consumer application in C# which connects to multiple remote clients over TCP. Since it's C# application, each client is monitored by a Task whose purpose is basically to run a ...
1
vote
1answer
67 views

Worker pool running tasks of the same kind serially

I would like to run tasks in parallel. At this time, I am using a very simple worker pool using a single concurrent queue shared by all the threads. Every task has a non unique "tag" (an integer in ...
6
votes
4answers
480 views

Performance: Is There a Reason to Use Processes over Threads?

This is a general question but I work in the .NET world so I'd like to know if there any specific quirks about the .NET Framework / Core platforms that I should be concerned about here. I think it's ...
1
vote
2answers
36 views

Multiple thread invocation in Rest Web Service

I have a scenario in our Web Application. GUI invokes a REST web wervice and further web service calls a procedure. However, the procedure returns data properly for most of the scenarios. In some ...
1
vote
1answer
59 views

Is my server design safe regarding multiple threads and concurrent database reads/writes?

I'm making a chat server using sockets and a MySQL database, and after it's working I want to expand it to become a more complex game server. I want to know whether my design is missing anything. ...
1
vote
1answer
50 views

What are the limitations of WinSock2 sockets within threads?

So I've run into some strange behavior on an application i'm developing in C using the windows API. Im trying to implement a closed connection server-client interface. However, for whatever reason ...
0
votes
0answers
94 views

How to design a fast way to `unarchive` file using python?

Assuming the following scenario: A python application that receives file and process that file trying to understand what the file format( any type of data/compressions/archives/packages/mounts/etc ),...
4
votes
4answers
168 views

Would it be possible to abstract multi-threading ability for programs not originaly designed for such?

Would it be feasible to provide (or further) multi-core threading ability for programs that weren't originally designed for such? And doing so by creating a "virtual" CPU core (or for i7's with ...
0
votes
2answers
255 views

How to avoid deadlock

I have queue of MoveableItems in a class BackgroundTaskQueue (based on example from Microsoft here). Clients call BackgroundTaskQueue.QueueBackgroundWorkItem to add a MoveableItem to the queue. An ...
0
votes
0answers
18 views

What is the difference between pthread scope vs. policy?

I'm reading OS Concepts for my undergrad OS class and came across this topic: Pthread scheduling (System and Process) Then I kept reading and came across POSIX Real-Time Scheduling that has two ...
-1
votes
2answers
119 views

Developing a C++ program on linux using two threads, always keeping one thread running

The title describes an idea of a solution to a more general problem. Here is the general problem: I am developing a program which looks roughly as follows: [read a lot of data, store in data ...
-1
votes
2answers
99 views

where to put Read/Write threads in c++ classes

I am programming a UART interface (in LINUX) and I want to use a class for that. The way I have it right now is I have a method for write and one for read. The reading is started in a new thread to ...
5
votes
2answers
406 views

Is it good approach to await async tasks in object destructor?

I'm currently working on class with some async tasks under the hood. In fact I need to delegate few tasks to asynchronous execution and be sure that all of them are finished before class was destroyed,...
2
votes
1answer
108 views

Parallel execution: 1 thread pool or N thread pools?

I have a tree generated by configuration. Each leaf of the tree is a long running task (like DB query, reading from file, etc.) that gives a result I want to store in a mirrored tree with only the ...
0
votes
3answers
167 views

How do you optimally and securely isolate processes when building an operating system from scratch?

I am trying to build software in JavaScript that emulates an operating system. For all intents and purposes, it is an operating system, even though it is JavaScript and we are running in the Node.js ...
0
votes
3answers
297 views

Multiprocessing vs multithreading

During my last job interview which was about half year ago, the technical guy asked me, whether the better option is to use e.g. 100 processes to do some work, or only one process but with 100 threads....
6
votes
5answers
940 views

Implementing a hash table with true concurrency

This was recently a question I was asked in a screening and it got me thinking. I never totally settled on how the conversation ended, and I did some digging. None of the answers I saw seemed ...
0
votes
1answer
63 views

Launch threads continuously with predefined interval between threads

I'm currently using a third-party API to fetch results, using a REST client (Retrofit). The problem is that the amount of requests per second that I can do to the API is limited with interval: I can'...
-2
votes
1answer
73 views

Does accessing RAM from 2 threads double access time (synchronous access)?

As in topic. If i want to access RAM from 2 different threads, completly different cells in memory, do they queue and are sent asynchronously or queue? Lets say accessing memory from one thread (...
2
votes
2answers
55 views

Design tips for waiting for a user input while working on another thread

I am working on an application with multiple threads (using Qt, C++). One of this threads is designed to execute a batch of operations like reading/writing from/to files as well as creating new ones. ...
0
votes
0answers
55 views

RS232 3rd party performance using C#

In my work i have an old fashion Vb app.. It's take single sale line(by text change event..) from the input and send it through RS232 output native. In purpose to get rid from any led display i took a ...
3
votes
1answer
111 views

Misra C, RTOS, and inter-thread communication

Currently I am developing an embedded system, running multiple tasks within an RTOS on a heavily constrained (mainly memory-wise) system. My team-lead advised the use of dynamic memory allocation. ...
-2
votes
1answer
43 views

Best Way To Take multiple TCP Connectons, Read the Incoming Data, and send that Data back into the Main Thread in Golang?

I want to take data from my goroutines and add them back to the main thread/goroutine. Problem is that I need the goroutines to stay open because data can come through the connection at any time in ...
0
votes
0answers
72 views

C++ client-server design

The context I need to design a Client-Server(-Client) network in C++ that would allow an android application to communicate to a Raspberry Pi and back I am running everything on linux environment(s) ...
0
votes
0answers
64 views

Where to put use case calling threads in clean architecture?

I've just started using clean architecture, It's clean and nice, but I've found a bit confusing use case. My application should be able to register to update a token after some time, so I handled ...
0
votes
1answer
53 views

Multithreading with duplicate matrixes? [critique/insight wanted]

I'm working on a video streaming project for drones with opencv where I want to apply multiple stacked image manipulations on a 2D input matrix. I was advised to make all manipulations calls non-...
2
votes
1answer
46 views

How do i call an unreliable API over network? CompletableFutures vs try catch block in Runnable vs something else?

I have to call a critical API over a network (which makes it unreliable) many number of times in a go, many times a day. If the API fails to respond (timeout) or returns an error (because that server ...
0
votes
1answer
91 views

Should I separate send and receive methods into tasks for a CAN-BUS reader on ESP32?

I am developing a CAN-BUS reader (logger) with an ESP32 microcontroller. This sample uses RTOS and several task to send and receive CAN-BUS messages. https://github.com/espressif/esp-idf/tree/master/...
2
votes
2answers
128 views

Name of locking approach

I've seen this approach several times, both in async and multithreaded code. A counter is used to track asynchronous behavior or thread behavior - whenever a new action is started, the counter is ...
0
votes
3answers
126 views

Can a thread acquire another sychronized block if it already has a lock of synchronized block

So my question is if my thread A has acquired access to a synchronized method S1() can it acquire access to another synchronized method S2() or a normal method.
0
votes
0answers
42 views

Pausing threads calling the same method by making them try to lock an already locked mutex

I am confronted to a question regarding synchronisation between threads having shared data. This is a stripped down versino of my class : class Foo { private: boost::mutex m_mutex; std:vector&...
0
votes
0answers
62 views

How to send messages in the order they were queued, while ensuring that client B does not have to wait until client A has received his message?

I have a simplified producer/consumer pattern implemented below. The code outputs: "A" 1 second delay "B" 1 second delay "A" 1 second delay "B" ... What ...
1
vote
1answer
203 views

Throttling the factory function of a Lazy<T> instantiated with LazyThreadSafetyMode.PublicationOnly

When you use the constructor of Lazy<T> requesting the valueFactory and mode parameters (I mean this one) you can specify LazyThreadSafetyMode.PublicationOnly. This way you can prevent the Lazy ...
2
votes
2answers
97 views

Having tasks that can be ran individually or “in trees”, and each task can be blocking or non-blocking

I'm creating a framework that needs to execute certain tasks, I'll use building a car as an example for this. So, an individual task could be something like weld metal or screw bolt. But there are ...

1
2 3 4 5
13