473,383 Members | 1,984 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

pth_select not blocking

12
I'm using C++ in Linux to read UDP and TCP sockets. I am now trying to impliment multithreading using pthreads.

pthreads has forced me to replace many of the standard socket functions (select, sleep, send, etc) with "pth_" replacements (i.e. pth_select, etc).

Problem is that pth_select isn't blocking. I.e. it isn't waiting for something to come over the sockets, it's simply checking the sockets then continuing. Sort of like what would happen if the time-to-wait before timing out was set to zero.

Thus I'm using all my CPUs to simply run around a while loop constantly checking the sockets.

This code worked fine before pthreads and pth.h was introduced, i.e. I'm confident that I actually have a wait time defined because it was waiting before.

Any help or directions to help would be very welcome. Thank you in advance.
Jun 13 '07 #1
2 1347
weaknessforcats
9,208 Expert Mod 8TB
Usually for a thread to wait on another thread it has to check an event. The second thread can signal the event (raise the semaphore) and this can be picked up by the first thread as the OK to continue. Think traffic lights.

Have you set up semaphores?

Check your docset for thread handling.
Jun 14 '07 #2
DBuss
12
The problem isn't with the threads directly, I can comment out all thread issues so that I only have the main.

Select (and thus pth_select) are supposed to wait for the socket to hand me information (which I then intend to hand to a sub-thread but that's a moot point with it commented out).

I found a report claiming Select had problems in combo with threads (which I can confirm) and I was supposed to use the replacement pth_select.

Pth_select isn't blocking, i.e. it's not waiting for information to come over the socket. Thus I'm using 100% of my CPUs to check and re-check the select for information when it's actually supposed to continue only if it actually finds something (or times out).
Jun 14 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Hal | last post by:
I am experiencing blocking problems on SQL Server 2000, SP3a. I have read the posts and set up a job SQL agent to report on these occurences I save the results to a table before executing an sp to...
3
by: David Sworder | last post by:
This message was already cross-posted to C# and ADO.NET, but I forgot to post to this "general" group... sorry about that. It just occured to me after my first post that the "general" group readers...
3
by: Mario | last post by:
Hello, I couldn't find a solution to the following problem (tried google and dejanews), maybe I'm using the wrong keywords? Is there a way to open a file (a linux fifo pipe actually) in...
7
by: Michi Henning | last post by:
Hi, I'm using a non-blocking connect to connect to a server. Works fine -- the server gets and accepts the connection. However, once the connection is established, I cannot retrieve either the...
3
by: loosecannon_1 | last post by:
I get a 90-120 second blocking when send 15 or so simultaneous queries to SQL Server 2000 that query a view made up of two joined tables. After each query is blocking for the same amount of time...
1
by: opi | last post by:
My blocking TCP server hangs in the Accept method when the client software sometimes gets an error. Are there any ways to stop this blocking in the Accept method so I dont have to restart the...
1
by: =?Utf-8?B?Sm9hY2hpbQ==?= | last post by:
I have an unmanaged C++ project which acts as a TCP client. However, the C++ client uses non-blocking mode and the tcplistener in the C# project is blocking. I am not sure if this matters, but I'm...
3
by: mp | last post by:
Code is at bottom. Basically, if I turn off socket blocking prior to connecting, I get a "Socket is not connected" error when I try to send data. However, if I do not turn off blocking, OR if I...
12
by: puzzlecracker | last post by:
is it even possible or/and there is a better alternative to accept input in a nonblocking manner?
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.