General :: Regarding Coding Multi Threaded Applications In C/C++?
Jun 15, 2010writing multi threaded programs in C,C++.
View 3 Replieswriting multi threaded programs in C,C++.
View 3 RepliesI ran into an inconsistency in handling timers (VTALRM) between AMD and intel platforms with threads. My understanding was that the timers are per process. I discovered I must call setitimer in the thread on intel though. AMD allows me to make the setitimer call once in the main thread as expected. The code below demonstrates the issue. I must add the code in the INTEL define for it to work properly on intel cpu's. Am I missing something dumb??
[Code]...
For quite some time now, I've been trying to implement a multi-threaded or forked TCP server to perform the following action:1) Listen for new connections on all ip addresses on a specific port.2) Wait for a new connection to arrive3) When a new connection coms in, fork or thread to free up the listening process so it can go back to #2.When handling a client after it's been forked/threaded4) Get the connected client's ip address.5) Perform some in-house processing;6) Read the data sent from the client (checking for http connections)7) Perform some more processing;8) Write some data back to the client based on the above processing9) Close the socket/thread/forkI've tried implementing an solution similar to the multi-threaded example show here http://perl.active-venture.com/pod/p...-sockets.html; as well as looking at the CPAN solutions Net:aemon and POE::Component::Server::TCP but these don't seem to give me the information needed.The active-venture solution provides me with what I need, but randomly exits without reason/error and when attempting to change the 'for' loop to a 'while' loop, it keeps throwing up different errors.
View 2 Replies View RelatedUsing Ubuntu server 10.04.2 64-bit all up to date.
I am running multi-threaded processes. These use OpenMP in my own code and the multi-threaded ACML maths library. When run in the foreground, everything is fine i.e. if I have set
export OMP_NUM_THREADS=8
then when I start all 8 cores are in use and things whizz along. However, when running overnight and logged out using e.g. 'at now + 1 minute' then the command, I am only getting about 130% CPU and it slows down accordingly. I have tried renice'ing and calling from within a bash script in case sh is doing something odd but nothing seems to solve it. I am sure that in the recent past this wasn't the case.
The libraries being used are shared versions in case that might have any bearing.
I'm trying to add local sockets in my multi-threaded application in order to exchange data between threads. The only problem I got is that most of the information available on the net is related to internet oriented socket programming whileI want to perform local connections. got a thread that does the sniffing via libpcap. And I would like that thread to send each captured packet to a second thread that will analyse the packetof the thread implementations is written in separate .h file.Or maybe there is a more effective method of exchanging data between threads
View 14 Replies View RelatedI am implementing a proxy server in c++. It is multithreaded(posix).Used CPU : Xeon(8core) Thread number : 8 One main thread, and other 7 thread created by the main thread. The main thread always listen to ports. When the main thread gets a client data it push the request in a queue[there are one queue(total 7) for each thread] based on ip and then give a signal to the appropriate thread. Then that thread gets the request from it's queue and process data and then forward the data to a appropriate destination.
There is another important thing, I assign each thread excluding the main thread to individual core by using affinity.The main thread listens to 5 ports. Test environment: We run the server. The client sends audio data at a particular rate.
1. The main thread CPU usage gets overloaded (above 80%) after a certain load from client.
2. Other cores remain about 0-10%.
The thing is that we want to distribute the load among all the cores equally by multithreading. But how can we do this ? Can the listening task of ports also be distributed ? I need an efficient algorithm for load balancing among threads. The data sent and receive rate of server is about 8.5MB/s. How can we improve this ? we are using gigabit LAN card. When the server only receive data from client it can receive data above 80MB/s. But when it both receives and sends data simultaneously it only manage upto 8.5MB/s.
Does anybody know any programs that might facilitate the spanning of a hard drive over multiple DVDs? I would like to backup a windows system that may have become corrupted however; but I don't know how to automatically span the files over multiple DVDs (which is what I'd like to do.) I may or may not use Ubuntu, but does anyone know any good applications for this?
View 2 Replies View Relatedis there a driver or application / media player that will allow me to use camstream,kopete cheese on the same camera at the same time.and let flash web sites use the cam as well .
View 3 Replies View RelatedI want coding of packet sniffer that runs on red hat and use c++ language.
View 2 Replies View RelatedYes it's me again, about to ask a foolish question.I've ran man on this commands, but they don't make any reference to their color, nor is it mentioned in the Bible. As I go through such as /sbin what does the color of the commands mean, like arch is green, awk is blue, and then there is those that have a red background such as cgexec?Then I go into /etc and then there's yum.repos.d there is no man for it, so I typed it in and got "command not found", so then I went in SU mode and "vi yum.repos.d and I get "yum.repos.d" is a directory,No such file or directory. So just what is yum.repos.d, I thought this is where I add more repositories.
View 3 Replies View RelatedI was asked to do a project on channel coding with different techniques. FEC, ARQ and Hybrid. Does NS2 support such coding?
View 2 Replies View RelatedI am trying to see how programs for cdroms use reed-solomon coding. I looked in the site lxr.linux.no , but couldnt get anything there, too much details present.
View 2 Replies View RelatedIn Fedora, I used the ls -l command to see the directory listing. But I noticed that while all .c files were being shown in green , there was one .c file which was being shown in black.How can two files having the same extension be executable /normal?
View 1 Replies View RelatedI need a tool to convert lots of C codes to a unified coding style. What tool can I use in Linux ?
View 1 Replies View RelatedI have an ATI Radeon HD 3300 on-board video chipset, and an ATI Radeon HD 4350 PCI card. What I want is to have both displays available from one mouse/keyboard. I want to play media on one and have the other as my main desktop.The problem is that with Xinerama enabled, KDE desktop effects do not work (KDE says XComposite and XDamage are not available, even though I explicitly enabled them as extensions in the xorg.conf file), and performance is quite bad. Without Xinerama enabled, performance is great, desktop effects work great, but there's a lot of trouble with full-screen video, and the KWin window manager does not apply in the second display (although I can run a second instance of KWin on :0.1).
View 2 Replies View RelatedAnyone successfully using VNC client on a Mac to control a Debian server?I have the vncserver setup on the Debian machine properly. But I'm having problems connecting to it from both a PowerMac running Tiger and a MacBookPro running leopard.I can connect no problem from a machine running Slack12.2, have not setup port forwarding on my router to connect remotely yet.My Debian machine is running the latest stable release of squeeze with KDE4.I originally tried this with RealVNC Enterprise for OSX but I'm not gonna buy it so I need another alternative after the 30 day trial ends as they have no free version for OSX.
The situation is that I do freelance graphic design on the PowerMac with Cinema4D and Photoshop so I spend most of my time on that machine which is located in my home studio in my attic. Aside from the MacBook and a Dell desktop(family machine)all my other machines and network hardware are in the basement. So to go from the attic to the basement everytime I need to do something on another machine is not practical, and the only other machine I need to access on a regular basis is the Debian box in the basement, this makes the most sense.
I also have a 14 year old living in the house and he's fascinated by all this and will meddle in anything he gets the chance to so all the Linux machines and network hardware need to be behind lock and key.
Now that Ubuntu 10.04 has multi-touch capabilities built-in, if I do not have a multi-touch screen or surface device, can I get 2 USB mice and get 2 pointers on the screen? One for the right hand and one for the left hand as I am ambidextrous, and would find it very convenient to have 2 mice.
View 4 Replies View RelatedIm running 64bit centos 5.6 and using virt-manager.On one of my guest OS's, Windows 7, The max Physical CPUs is 2, you can have unlimited CPU Cores however. (like my machine i use for work has 1, 4 core processor).The issue im having is xen only allows you to set the vcpu arguemnet in your xen config file. How can i set it so that 1 CPU has several Cores just as windows would recognize this machine if i were installing directly to the hardware vs via a VM.Ive searched for 2 days staright trying to address this issue, very little progress, Does anyone know where a XEN support forum is? all i get is the citrix xen support forums.
here is the best info i have found on this, but i dont know how to change this for my CPU to work, when i enter this in my xen config it essentially ignores it and just takes the value of vcpu= so windows shows 2 CPUs each with ONLY one core. Id like 1 or 2 CPUS showing Several cores.The physical Hardware is 2x Xeon 5300 Quad Core CPUs.
> # Expose to the guest multi-core cpu instead of multiple processors
> # Example for intel, expose a 8-core processor :
> #cpuid=['1:edx=xxx1xxxxxxxxxxxxxxxxxxxxxxxxxxxx,[code]........
I am writing a script that will ping a server and then do a command if it gets a ping that is less than 100ms or more than 100ms. Basically, I need to have a variable for the ms.
Here is an example script.
Code:
Now, all I need to do is get a variable from the ping. I know I can do this:
Code:
But that just sets the whole line, I only want the ping, without "ms" at the end.
So basically, if I ping 25.25.25.25 and get 43.872 ms I want $pingms to equal 43.872.
Also, how can I do this with free, for example:
Code:
I want $ramavail to equal the amount available and I want $ramtotal to equal the total amount.
Below is my code to create *.bz2 file.
<?php
//Moving file to temporary directory for compression
move_uploaded_file($_FILES["file"]["tmp_name"],"c:/" . $_FILES["file"]["name"]);
$url="c:/".$_FILES["file"]["name"];
//File compression
[Code]....
Anyone know, how to unzip the file ? I've tried the above code to unzip it but it creates only 1kb of file for any files.
I recently downloaded Metasploit framework for ubuntu but i got an error which says could not open <file location>
Saying gedit has not been able to detect the character coding. Check that you are not trying to open a binary file.Select a character coding from the menu and try again
What sort of libraries can i use for coding of sniffer program for windows and linux? The sniffer that i want to code is for capturing the list of connected clients to AP wirelessly. I do know that the wireless NIC needs to be in 'monitor' mode in both windows and linux.
View 4 Replies View Related[URL]...In this bug, you'll see that I actually fixed my own problems that surfaced when building GNOME Shell from source.
View 1 Replies View RelatedI'm working on RHEL5 dealing with AS (ActionScript) files in Linux GVIM Editor but everything is in blue color. Can i set color coding for my keywords?
View 3 Replies View RelatedZen-coding is a great gedit plugin for html & css development.I download the files and unpack them into ~/.gnome2/gedit/plugins/.After open gedit I can't find zencoding in the Gedit Preference.
View 9 Replies View RelatedI'm doing some shell scripting in nano, but code is much simpler to read when is color coded.... is there a terminal editor that supports color coding?
View 3 Replies View RelatedI've been a PHP developer for about 6 years now - the last two years I have been pretty inactive though. Just recently though, I have been reading resources on all the different programming patterns (Factory, Singleton, Registry, Observer, MVC, etc) to try and get my head around good programming techniques. For myself though I find that I can only truly understand how these methods work when I am forced to do them myself.I have a large project I am doing at my workplace (me only) that involves building a very complex PHP application.
I would like to know your professional opinion; should I spend the extra time to program this PHP application myself and really, properly learn all these different programming patterns? Or, should I just build on top of a PHP framework like the Zend Framework for speed's sake (and flexibility/features)?
I have found understanding exactly how the Zend Framework works hard, just because I haven't been exposed to using these programming patterns myself. I hate that - I want to fully understand exactly what is happening in my application and know exactly how each part relates to others.
i am using front end as java and back end RHEL5.i am trying to calling a bash script with java. but i am facing problem.i am using following java coding to use call the bash script
import java.util.*;
import java.io.*;
public class b
[code]....
Can I get someone that is using Ubuntu/Lucid and Firefox as browser to run a test for me? Can you go to this website and then type the either the word "HIGH" or the word "LOW" in the search box and then tell me if you get the same bunch of program error codings that I get when I try this ? Want to see if this is a problem with just my computer setup or with the websites programming. [URL].
View 2 Replies View RelatedI hesitated on the title, generally can solve problems w/o this (20+ year *nix/linux experience).
hardware Dell 1505, ATI X1400 (nVidia went south replaced with ATI, used at this stage of life for this laptop).Acer x221w external monitor.
Recently upgraded to 10.04 (should have waited, but hadn't upgraded in a long time).
No real fixes found for the ati X1400 in searches (fixed it on 9.04 and 9.10).
So to troubleshoot, wanted to go to console mode, and start X manually and hopefully debug the config to get the thing working.
So, I get ready to take it down off of X only to find, there are no more consoles???
To work this out and to even come to an end result, when X does not work, you need a console to debug it. There is code in /etc/init.d/console-screen.sh for starting consoles...
Yet they do not start, notices some comments about doing it 'clever' in there, all I can say is 'clever' is more risky than workable, it worked before, why change it? It did not make it better, it made it harder, so now, to get it to work, I have to go debug someone else's 'clever' code? BTW, there are 'getty' running - but still no console.
Not so clever... We need a fix to get (at least at this level), the consoles running, so, where are you 'clever coder', tell us how to turn them back on.
Why in /etc/init/tty*.conf do they not start?
I really find it hard to say anything critical to something that is free, in general, I will not even comment, but just go ahead and find the fix myself, But to even address this, we (IMO) need pretty much a fix for the broken console access, before we can even address X in certain configurations.
A long time user of RH, even back to Yygdrasil, Soft Landing days, I was VERY impressed with ubuntu over the others for a desktop (got it on the Dell), but now, at 10.04, it has become cumbersome and broken.
It is a good product, but we need to get it back to where it is not so bleeding edge and broken.