Programming :: Create A Separate Thread For Program Which Basically Polls Using The Read Command?

Sep 28, 2010

I'm trying to create a separate thread for my program which basically polls using the read command. However this new thread seems to block the main thread, anyone know why this could happen.

In main I call this function pthread_create(&mainEventThread, NULL, GenericEventThread, NULL);

which calls
/*New threads start function */
void *GenericEventThread()
{
short int i, nError = -1;

[Code]...

I've used pthread_self to check that a new thread is being created, so why is the while loop in one thread blocking the main thread from running, I haven't used the join function anywhere in my code.

View 2 Replies


ADVERTISEMENT

Programming :: Create A Simple Program With Will Continually Read Input From The User Until They Enter A Blank Line?

Apr 6, 2011

basically i have to create a simple program with will continually read input from the user until they enter a blank linei know how to read in certain input but not sure how to get it continually in a loop

View 2 Replies View Related

Programming :: Create The Thread Which Runs Then Drops Out?

Mar 11, 2010

I hope someone can help me with this. I need to call the same thread multiple times, but only run one thread at a time. So what I do is create the thread which runs then drops out. Run the main loop and after some time pthread_create the same thread again. So in pseudo code

[Code]...

I always presumed if I run a thread and it reaches with a pthread_exit, then the thread was destroyed? However I've found that after I've created the thread several 100 times the programme crashes? So can anyone advise how I call the same thread over and over?

View 10 Replies View Related

Programming :: How To Bind Thread To Specific Thread In Multithread Application?

Dec 25, 2010

I am going to use "pthread_setaffinity_np" to bind a thread to a specific core. My application has two threads. I have used mutex to assign a specific id to each thread and then bind that thread to a core different from another core. but it seems that the os assigns both thread to one core.What should I do to bind each thread to a specific core?

View 4 Replies View Related

Programming :: Run A Command On A Separate Terminal In A Bash Script?

Apr 6, 2011

I'm trying to do something here:: I'm writing a bash script, I want to [open a new terminal and run a bash command in it] inside the script. I tried to use this, but apparently I get syntax errors.

Quote:

#! /bin/bash
echo "echo Something" > ~/Second.sh
chmod +x ~/Second.sh
xterm -e sh -c ./Second.sh

View 14 Replies View Related

Software :: Create User With Password And Read / Write Privileges For Program Database

Oct 11, 2010

Unless your distro has taken care of it Centos 5.5, you'll need to create a user with a password and read/write privileges for program database. You can do this using the MySQL command line client if you are familiar with it. Well I am not familiar with it, so I wam wondering how to do it. As well when I run

mysql - p program </usr/share/program/mysql.sql>

It asks for a password. how do i find out this password.

View 1 Replies View Related

Programming :: Pthread - Take String From The Command Line And Creates A Thread To Print The String

May 3, 2011

I've been trying to understand pthread in C a little better. So I made a simple program that takes in a string from the command line and creates a thread to print the string. I've looked online and copied the basic concepts but there are something things I'm confused about. The programs works just fine, but I have questions. Here's what I have so far.

[Code]....

One thing I'd like to know is why the 3rd argument in the pthread_create function which is my SendMessage function needs to be typecasted to a void pointer and then send the address of the function. Also as for the 4th argument, I would see typecasting to void pointer in some of the pthread examples I saw online, but in my case I'm passing a char pointer, would this be correct? In which case would I ever want to pass a void pointer?

Do I need a pthread_exit(NULL) in my main and in the SendMessage function? If so, why? I added the sleep() function so that I could let the pthread_exit function in my SendMessage function execute first. I simply saw that the online examples on pthread had pthread_exit() in both locations.

View 6 Replies View Related

Programming :: Write A Program Which Will Read Input From A Text File

Apr 7, 2010

i am trying to write a program which will read input from a text file, check if each line contains any alphabets and then display a message imforming me if there is an alphabet in each line. My text file is formatted in this way...

[Code]....

View 2 Replies View Related

Ubuntu :: How To Create A Shortcut To Open Command Line Program

Feb 21, 2010

I use a few command line programs quite often such as nano and mpc. I'd like to create a shortcut icon to open them rather than opening a terminal and then typing in the program name to open it. For example, how could i open konsole with nano opened in one step?

View 5 Replies View Related

Programming :: Create A Program In C++ In Opensuse 11.4?

Mar 28, 2011

I`ve just installed opensuse 11.4 and i dont know how to write and compile my programs
is there a compiler like turbo c++ to use??

View 5 Replies View Related

Programming :: Script To Create .menu File (recursively Read Directories)?

Nov 4, 2010

I've found myself in the situation where I need to create a menu in gnome/kde for a directory structure full of documents.The directory structure looks like this:

Code:
DOCS/
.. REFERENCES/

[code]...

View 1 Replies View Related

Software :: Read Process/thread Schedule Information?

Nov 18, 2009

is there any tool can show the thread/process schedule information? i would like to know when the thread/process wakeup, and when it was suspend? it includes kernel and user space. With this information, i can know the thread/process task schedule, and calculate the MIPs.Another, do you know whether LTT support User space thread trace?

View 2 Replies View Related

Programming :: Create Unique Multithread Algorithms For Every Particular Program?

Aug 6, 2010

Since 2005 when DualCore CPUs came out, you need to create unique multithread algorithms for every particular program? Or you have patterns?

View 4 Replies View Related

Programming :: Create A Screen Capture Program With Xvfb Server?

Jan 4, 2010

I am trying to create a screen capture program with Xvfb server, ImageMagick and Khtml2PNG. I seem to be having some issues and was hoping someone could help me out. I have everything installed and working on a centos WHM/CPanel system and am able to generate the screen shots and save them to root folder from shell with the following commands.

Xvfb :2 -screen 0 1024x768x24&
export DISPLAY=localhost:2.0
khtml2png2 --sw 200 --sh 150 http://www.example.com example.png
It works 100% fine when you run it from shell.

[Code]...

View 4 Replies View Related

Programming :: Using Expr Command To Read Values From Two Different Files?

Mar 20, 2011

I have an assignment where I have to use an expr command to read values from File1.txt and File2.txtHeres the assignment:Create two files.File1 has one line with the value of 5.ile2 has one line with the value of 100.Edit your new file using Gedit or VI and change it so it performs the following actions:Read the values from the files above (file1 and file2)Divide the value from file2 by the value in file1.utput the result of this calculation to a new file called file3. My .scr file is week3prog3_george, in file1 I put var1=5, file2 is var1=20.Then, I put in my .scr file this:

#!/bin/bash
expr File2.txt / File1.txt

It returns an error message stating "non-integer argument."And...how do you point the .scr file to read values from two different files, and the book my school has provided does not contain the info I need.

View 1 Replies View Related

Software :: Ftp Program That Allows For Multi-thread Ftp Uploads?

Feb 3, 2009

I upload picture files to an ftp server. I can't do much about my upload speed but I think that a multi-thread upload may yield the same kind of improvements that a multi-thread download yields.

View 4 Replies View Related

Programming :: How To Create Sed Or Awk Command

Apr 7, 2011

How would I create a sed or awk command that would add a | to the end of a line if it wasn't already there? I'm trying to import some files into mysql, but some of the lines to not end with a | which is my field delmiter.

View 14 Replies View Related

Programming :: Create Large Buffer In Program To Send And Eceive On Another Pc More Than 4096 Bytes

Feb 9, 2011

create a large buffer in my program so that I can send, and then receive on another pc, more than 4096 bytes (this seems to be the default for the serial port). I thought this might work:

[code]...

View 9 Replies View Related

Programming :: Create A RS232 C Program That Executes A Series Of Commands Down The Line To A Robot?

Jan 5, 2011

I am trying to create a RS232 C program that executes a series of commands down the line to a robot. Everything seems to work fine, except any sequential write to the serial port. At first I thought it was the UART's buffer being filled too fast, but even with a 50 uS delay it still throws the error.

Here is my code:

Code:
#include <termios.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/signal.h>
#include <sys/types.h>

[Code]...

View 1 Replies View Related

Programming :: Unix Programming - Single Thread Server Can Support Exactly 2 Clients At Once

Sep 28, 2010

A simple TCP based chat server could allow users to use any TCP client (telnet, for example) to communicate with each other. For this question you should consider a single process, single thread server that can support exactly 2 clients at once, the server simply forwards whatever is sent from one client to the other (in both directions). Your server must not insist on any specific ordering of messages as soon as something is sent from one client it is immediately forwarded to the other client. As soon as either client terminates the connection the server can exit

View 4 Replies View Related

Programming :: Can't Find Command, But Program Is Installed?

May 14, 2010

WindowsDude is back on the dark side of the web, the linux world, and he has encountered yet another impassable problem !There's a compiler mpicc, probably installed on the network at some location let's say /network/bin So when I write mpicc main.c I get the "can't find command" (or similar) error. Somehow it's supposed to work anyway. I think I need one of those magic commands to make it work. But the question is; which word will make it all happen? (I thought the DOS days were over!) I guess I could use the full path (provided that that binary really is in that folder), I want to bind that executable at that location to the much shorter mpicc.

View 3 Replies View Related

Programming :: Program That Activates A Command-line?

Feb 7, 2010

I am wanting to write a program that runs a program or command-line. Is there are way of making a program that activates a command-line (for example executing 'ps -a -f' or '/home/shared/fah').

In addition to that, I want the program to do a 'ps -a -f' and put the results in a buff, how could I do this.

View 5 Replies View Related

Programming :: Bash Shell Read User Argument From Command Line And Test It

Aug 29, 2010

Trying to create a small script that will read user's input, test if user entered some input and if not display some message or display a text using user's input.

The script is the following but i get an error saying "[: 6: =: argument expected"

View 12 Replies View Related

General :: Create A Signal Handler Thread To Handle SIGALRM Signals?

Jan 19, 2010

I'm trying to create a signal handler thread to handle SIGALRM signals. The main thread calls the following function before creating any other threads

Code:

pthread_t Timer::Init(long _clock_interval_musec)
{
// Set interval.
clock_interval = _clock_interval_musec;
// This is called while in a single threaded environment.

[code]....

clock_interval is 50.

Is the timer not firing? Did I not set my interval correctly? Did I not proper block the signals ensuring the that the default handler would not take care of them?

View 7 Replies View Related

Programming :: Using Command-line Options With A Program That's Called Using Env

Oct 11, 2010

I thought about this a while ago when reading through a Python tutorial and I googled some and couldn't find an answer. Now I want to know it for Ruby, also, and it's more important now because I want to invoke Ruby with -w.

How can you use:

Code:

with a -w option to ruby, like:

Code:

This doesn't work and I can't find an explanation of how to do it.

Code:

View 1 Replies View Related

Programming :: PyGTK: Can't Seem To Launch Program - Gobject.spawn_async Command

Jul 20, 2010

I need to launch a program, throw up a pulsing status bar and then close it when the program quits. I cannot seem to launch the program (a bash script):

[code]...

This is where I'm getting my information: [URL]...

View 1 Replies View Related

Programming :: Orrect Command To Create A Named Pipe File?

Apr 22, 2010

My question deals with me creating a name pipe (file) in the my /group directory called chat.I then have to write a script to read from the named pipe and save data into a file called chat.log until the words End of File are passed to the program.

-When I created the named pipe file (chat) I used the mknod chat p command..Is this the correct command to create a named pipe file? -Then I'm having trouble with my script and how to make it run until the words End of File are entered in. This is what I have so far.

View 6 Replies View Related

Programming :: Python - Call Function From The Command Line After Compile The Program?

Dec 28, 2010

If i have a python file with a function call_me(a,b),how can I call this function from the command line ,after i compile the program?

View 5 Replies View Related

Programming :: Write A Bash Script Program In System Command Terminal?

Mar 22, 2010

I'm trying to write a bash script program in the Linux command terminal that will write to a fellow user and then continue reading down the program. this is what i have (kind of explains the idea too):

#!/bin/sh

clear
echo "this is before the write command"
write jcummins
this message should go to jerry
echo "the message didn't send and this string will not appear"
echo "it appears it has stopped at the write command"

View 5 Replies View Related

Programming :: Quickest Way To Get Thread Id

Jun 24, 2010

What is the quickest way to get the thread id(tid) of the current thread in linux? Specifically I use fedora 13. ...and I am talking about inside a C++ program.

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved