I have the following code which replicates the windows manual and auto reset events.
class event
{
public:
event( bool signalled = false, bool ar = true ) :
_auto( ar ),
_signalled( signalled )
{
pthread_mutex_init( &_mutex, NULL );
pthread_cond_init( &_cond, NULL );
}
~event()
{
...
I'm taking a class in computer security and there is an extra credit assignment to insert executable code into a buffer overflow. I have the c source code for the target program I'm trying to manipulate, and I've gotten to the point where I can successfully overwrite the eip for the current function stack frame. However, I always get a S...
I am actually on my project on compiler with SMP, and want to code with pthreads and heard about many parallel things open mpi and so on, So to start with how this thread is allocated to core while calling pthread,Is there any way to give threads to different cores by pthreads?
...
I'm experimenting with multithreading in Windows and was wondering whether I should
use Win32 API
use POSIX Threads for Windows
Learning Pthreads would be useful if I tried to develop such applications on different platforms - but am I losing anything by not learning Win32 API? Or are both similar enough so that learning one allows m...
I'm using read/write locks on Linux and I've found that trying to upgrade a read locked object to a write lock deadlocks.
i.e.
// acquire the read lock in thread 1.
pthread_rwlock_rdlock( &lock );
// make a decision to upgrade the lock in threads 1.
pthread_rwlock_wrlock( &lock ); // this deadlocks as already hold read lock.
I've re...
I am working in multithreading application, application is facing some problem while processing the request.
When i kept load on multithreaded application,it is working fine up to some time.After some time it is not able to process any request.At this situation when type this command,
ps -eLF | grep multithread
all threads are showing...
The following code is a simple thread game, that switches between threads causing the timer to decrease.
It works fine for 3 threads, causes and Abort(core dumped) for 4 threads, and causes a seg fault for 5 or more threads.
Anyone have any idea why this might be happening?
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
...
I have a hard problem here, which I can not solve and do not find the right answer on the net:
I have created a detached thread with a clean up routing, the problem is that on my Imac and Ubuntu 9.1 (Dual Core). I am not able to correctly cancel the detached thread in the fallowing code:
#include <iostream>
#include <pthread.h>
#inclu...
This is somewhat similiar to this : http://stackoverflow.com/questions/1151582/pthread-function-from-a-class
But the function that's getting called in the end is referencing the this pointer, so it cannot be made static.
void * Server::processRequest()
{
std::string tmp_request, outRequest;
tmp_request = this->readData();
...
Hello
pthread_cleanup_pop_restore - what is it?
It is from glibc. And it is called too often and eats a lot of cpu time.
The program uses a lot of getc() calls. I can't change the program (it is the benchmark with fixed source), but want to make it run faster.
...
I have both matrices containing only ones and each array has 500 rows and columns. So, the resulting matrix should be a matrix of all elements having value 500. But, I am getting res_mat[0][0]=5000. Even other elements are also 5000. Why?
#include<stdio.h>
#include<pthread.h>
#include<unistd.h>
#include<stdlib.h>
#define ROWS 500
#defi...
I'm just starting to learn how network programming in C works, and I've written a small program that sends messages to and from a UNIX terminal. I'm using pthreads in my program, one of which essentially just waits on recvfrom() to receive a message.
However, I want to be able to close all threads properly if the users chooses to quit t...
I have a program that uses pthread library to do the matrix multiplication of 500x500 matrix. Each thread calculates 50 rows of the matrix.
When I run tiem command:-
shadyabhi@shadyabhi-desktop:~$ time ./a.out
real 0m0.383s
user 0m0.810s
sys 0m0.000s
shadyabhi@shadyabhi-desktop:~$
How come sys+user is greater than real tim...
I am playing with C++ and pthreads and so far so good. I can access a class member function if it's static and I've read that I can access a normal class member functions if I pass "this" as an argument with pthread_create, because c++ does this to, under the hood. But my problem is that I want to give an int to that function, and I don'...
Hi.
I'm synchronizing reader and writer processes on Linux.
I have 0 or more process (the readers) that need to sleep until they are woken up, read a resource, go back to sleep and so on. Please note I don't know how many reader processes are up at any moment.
I have one process (the writer) that writes on a resource, wakes up the reade...
Sockets on Linux question
I have a worker thread that is blocked on an accept() call. It simply waits for an incoming network connection, handles it, and then returns to listening for the next connection.
When it is time for the program to exit, how do I signal this network worker thread (from the main thread) to return from the accep...
I found there are also a pthread in Boost library, is it the same thing as the posix pthread?
...
Hi. I have a TCP Server application that serves each client in a new thread using POSIX Threads and C++.
The server calls "listen" on its socket and when a client connects, it makes a new object of class Client. The new object runs in its own thread and processes the client's requests.
When a client disconnects, i want some way to te...
Hi,
Could someone please tell us on how to print correctly the handling thread in windows? Actually I tried several ways but it doesn't return the right number as in Unix-variant, as such e.g.:
cout << " with thread " << pthread_self << endl;
cout << " with thread " << pthread_self().p << endl;
Thanks for your replies:
...
Hi,
I cannot compile this code under SUA:
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
void * thread_function(void *arg) {
printf("thread_function started. Arg was %s\n", (char *)arg);
// pause for 3 seconds
sleep(3);
// exit and return a message to another thread
// that may ...