nonblocking

MPI Non-blocking Irecv didn't receive data?

僤鯓⒐⒋嵵緔 提交于 2019-12-10 10:44:02
问题 I use MPI non-blocking communication(MPI_Irecv, MP_Isend) to monitor the slaves' idle states, the code is like bellow. rank 0: int dest = -1; while( dest <= 0){ int i; for(i=1;i<=slaves_num;i++){ printf("slave %d, now is %d \n",i,idle_node[i]); if (idle_node[i]== 1) { idle_node[i] = 0; dest = i; break; } } if(dest <= 0){ MPI_Irecv(&idle_node[1],1,MPI_INT,1,MSG_IDLE,MPI_COMM_WORLD,&request); MPI_Irecv(&idle_node[2],1,MPI_INT,2,MSG_IDLE,MPI_COMM_WORLD,&request); MPI_Irecv(&idle_node[3],1,MPI

Is console output a blocking operation?

可紊 提交于 2019-12-09 17:02:53
问题 When a Java program calls System.out.println() or a Scala program calls println() does the thread block? I'm writing a Scala program with a huge amount of subtasks. Each subtask is executed inside a Future. It is recommended that code inside actors and futures does not block, so that subsequent tasks don't have to wait, too. But I want to print very much on the console. And if it is a blocking operation: What can I do to optimize performance? Should I use a dedicated thread for console output

Bash script with non-blocking read

无人久伴 提交于 2019-12-09 16:50:17
问题 I want to send some data to a root process with a named pipe. Here is the script and it works great: #!/bin/sh pipe=/tmp/ntp if [[ ! -p $pipe ]]; then mknod -m 666 $pipe p fi while true do if read line <$pipe; then /root/netman/extra/bin/ntpclient -s -h $line > $pipe 2>&1 fi done I actually have several script like this one. I would like to enclose all of them in a single script. The problem is that execution blocks on the first "read" and I cannot execute multiple "reads" in a single process

Non-blocking sockets

心已入冬 提交于 2019-12-09 04:53:26
问题 What's the best way to implement a non-blocking socket in Java? Or is there such a thing? I have a program that communicates with a server through socket but I don't want the socket call to block/cause delay if there is a problem with the data/connection. 回答1: Java non-blocking socket , introduced in Java 2 Standard Edition 1.4, allow net communication between applications without blocking the processes using the sockets. But what a non-blocking socket is, in which contexts it can be useful,

Chaining of Promises via #flatMap() in Play Controller-Action

做~自己de王妃 提交于 2019-12-09 04:35:31
I'd like to ask if what I'm doing is suitable or if there is a better/more efficient/simpler way. Scenario: User logs in with e-mail-address and password, gets routed to the login()-action If the user is already in the DB and has a password hashed, authenticate with the DB-user and return result-promise If user is not in the DB or has no password-hash, do a web-service request with the login-data and parse the status from the response -> return a Status -instance Check the status of the user and return a result-promise Code: public Promise<Result> login() { Promise<User> userPromise = Promise

Volatile and Thread.MemoryBarrier in C#

岁酱吖の 提交于 2019-12-08 23:47:07
问题 To implement a lock free code for multithreading application I used volatile variables, Theoretically : The volatile keyword is simply used to make sure that all threads see the most updated value of a volatile variable; so if thread A updates the variable value and thread B read that variable just after that update is happened it will see the most updated value that written recently from thread A. As I read in a C# 4.0 in a Nutshell book that this is incorrect because applying volatile doesn

Sockets: What is causing read() to return EINVAL?

故事扮演 提交于 2019-12-08 23:13:29
A socket client program establishes a connection with the server, writes some bytes and waits for response using the (blocking) read() . But this fails with the error EINVAL ("Invalid argument"). Previous calls to create() , bind() and connect() the socket have been made successfully. My Question What's wrong here? Platform is Linux x64. fd is attached to an object which is unsuitable for reading; or the file was opened with the O_DIRECT flag, and either the address specified in buf, the value specified in count, or the current file offset is not suitably aligned. See http://www.kernel.org/doc

Non-Blocking Connect

試著忘記壹切 提交于 2019-12-08 17:41:54
问题 This question is not limited to Python. Its a general socket question. I have a non-blocking socket and want to connect to a machine which is reachable - on the other side the port does not exist. Why does select(...) succeed anyway? I expected a timeout. sock.send(...) fails with a broken pipe. How can I determine if the socket is really connected after select(...)? Thanks in advance. import socket, errno, os, time, select sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock

Greater-than compare-and-swap

≯℡__Kan透↙ 提交于 2019-12-08 14:45:53
问题 As the title suggests, I'm looking for a compare-and-swap implementation, but with greater-than comparison: if(newValue > oldValue) { oldValue = newValue; } where oldValue is some global shared state and newValue is private to each thread, without doing this: synchronized(locker) { if(newValue > oldValue) { oldValue = newValue; } } because I want a non-blocking solution. From studying source codes of other non-blocking operations, I've come up with this (assuming the values are integers):

Is wait(1) in a non-blocking while(true)-loop more efficient than using wait() and notify()?

穿精又带淫゛_ 提交于 2019-12-08 08:17:04
问题 Does a while(true) Java loop together with wait(1) use more or less resources than a blocking loop with wait() and notify() ? And do the CPU cores have some special (hardware) implementations to allow wait(1) ? If yes, are there any limitations while working with such non-blocking loops? An example: while(true){ wait(1); //do the job here... } (Just a note: Without the wait(1) a core would go radical 100% in a while(true) loop...) 回答1: As to the original question of why while (true); takes up