Programming :: Using Lock In OpenMP And Pthreads
Apr 14, 2011
I have a program that uses both Pthreads and OpenMP. Basically, 2 threads (Thread A and B) are created using Pthreads to do work, and in Thread A, OpenMP is used to parallelize a for loop.If I have a global variable that is accessed by the OpenMP threads and also Thread B, can I use the lock in OpenMP to ensure I have no race conditions?
View 2 Replies
ADVERTISEMENT
Feb 10, 2010
i think we can simulate preemption by using 2 different priority thread, am i true? I just try these scenario :
1. Create Thread A with priority 99 , SCHED_FIFO..
2. Create Thread B with priority 4 , SCHED_FIFO
Thread A started and doing some busy work.. I guess that Thread B wouldn't start until thread A finished, but I get thread B can run before Thread A finished (It just like a common task switching).. I'm sure my 2 thread has right priority. and if thread B is doing some work and if i yield it to thread A, it should preempt it but this doesnt happen, do someone kno wats happening?
View 1 Replies
View Related
Jun 29, 2010
I just started with Pthreads and don't really know much about it. I want to suspend pthreads but apparently, there is no such function as pthread_suspend. but I don't understand why we need both mutex and condition to suspend and resume a pthread. Is it possible to suspend and resume it without using conditions?
View 1 Replies
View Related
Jun 14, 2010
I have confusion regarding pthreads return value. All in short, is the is a valid return value ?
[source]
void * myThrRoutine(void *arg)
{
struct myStruct **myst = (struct myStruct**) arg;
cout<<"In thread "<<(*myst)->var<<(*myst)->msg<<endl;
int x = 20;
pthread_exit((void*)x);
}
[/source]
This seems to work fine on pthread_join , but I want to ensure it is not by chance.
View 1 Replies
View Related
Mar 16, 2010
I am trying to write a peer to peer application in C++ using pthreads library. There are few types of nodes that run in the program. The 'beacon' nodes form the core of the network. The ordinary nodes 'join' the network by sending join requests to the beacon node. So, my program runs till the join requests and responses are received. When I try to 'connect' using connect function from the socket library, I get a segfault. I am not sure if the segfault occurs for the connect function, because sometimes the program just runs to completion. It could be an issue related to threads or memory allocation.
When I run gdb, it shows me the following:
Code:
(gdb) run b2-n00.ini
Starting program: sv_node b2-n00.ini
servant:12600> [New LWP 1]
[New LWP 2]
[New LWP 3]
[New LWP 4]
[New LWP 5]
[New LWP 6]
Before Exiting[LWP 1 exited]
procfs: fetch_registers, get_gregs line 3768, /proc/23952/lwp/1: No such file or directory.
View 6 Replies
View Related
Sep 17, 2010
I don't seem to find a conclusive answer to this one...."Is popen thread safe via pthreads?"
View 2 Replies
View Related
Feb 17, 2010
I have created two threads:
Thread 1 and thread 2
In the main thread, i have put up a timer which generates a signal periodically when it expires, which reults in execution going to signal catcher function.when this function is invoked, under certain condition it goes to thread 1 and under another condition it goes to thread 2. The problem lies here that when it goes to thread2,i have a loop to process but it doesnt come out of the loop and hence from thread2, even though timer has expired.
View 2 Replies
View Related
Jun 30, 2010
I am running Yellow Dog Linux release 6.2(Pyxis) on my PS3. I would like to compile and run C programs that utilize OpenMP for parallel programming. Unfortunately, I have not been very successful. I am able to compile programs containing OpenMP statements error free, but when I attempt to execute the binaries I receive the following error: Code: ./file: error while loading shared libraries: libgomp.so.1: cannot open shared object file: No such file or directory Compiling programs without OpenMP statements works fine.
Because it has to do something with missing libraries, I am not sure if knowing the executable search paths may help in diagnosis, but when echoing the path environment variable:
[Code]...
The version of GCC on this machine, 4.1.2 20080704 (Red Hat 4.1.2-44), is identical to the ones I have on two other machines (CentOS release 5.3 (Final) and CentOS release 5.4 (Final)) and they both compile and execute OpenMP code flawlessly. I have tried building and installing another version of GCC that would possibly include the OpenMP libraries, since, according to some sources, GCC has only supported OpenMP since version 4.2. But I have not been successful with that either (that problem would make a good second thread.)
View 3 Replies
View Related
Mar 26, 2011
I have installed OpenMPI from ubuntu repository. However some users need openMp. The problem is I didn't find that in ubuntu repository. Where can I found deb packages? If I must install from source, then is there any conflict between openMp and openMPI?
View 4 Replies
View Related
May 3, 2011
Where can I find the rpms for OpenMP for SciLinux 5.5 for64bit computing?
View 3 Replies
View Related
May 21, 2010
I am playing around with pthreads. This program however blows up.
#include <iostream>
#include <pthread.h>
using namespace std;
struct myStruct
{
int a;
string msg;
};
void * myProc(void *arg)
{
struct myStruct* str = new struct myStruct();
str->a = 10;
str->msg ="hi";
return (void*)str;
}
int main(int argc, char **argv)
{
pthread_t mythr;
int status ;
void *retVal;
struct myStruct* m_str;
status = pthread_create(&mythr,NULL,myProc,NULL);
status = pthread_join(mythr,&retVal);
cout<<"Status is"<<status<<endl;
m_str = (struct myStruct*)m_str;
cout<<"retval is "<<m_str->a<<" "<<endl;
return 0;
}
Can a structure be returned by a thread as its return value ?
View 1 Replies
View Related
Jul 1, 2011
In my code I want to have two different functions to be executed simultaneously (in parallel) in a single processor system. I tried to use pthreads but they happened to be executed one after another. I have heard about fork, some saying that its no longer recommended since its functions can be achieved by pthreads.
View 1 Replies
View Related
May 3, 2011
i have two c++ programs, first one captures network packet from eth interface and save it in a file, second one uses this generated file for its purposes, data stream always exists then first program should always be running, although second program cannot read the file while the first program is writing in it, then i need to define a lock which can be checked by both progs before read/write, how is it possible to define this kind of lock in linux?
View 5 Replies
View Related
May 31, 2011
I'm trying lo lock a file (not using the chmod). This is the code I generated, but even locking the file I still can read and write the file from another process. (I'm working on a ubuntu 10.10, kernel 2.6.35-22-generic #35-Ubuntu SMP)
[Code].....
View 2 Replies
View Related
Apr 16, 2010
I need a module that flash Caps-Lock led. Is it possible to use outb() function here for sending data to keyboard via port 0x64 ?
View 2 Replies
View Related
Nov 22, 2010
I just downloaded OpenOffice 3.2.1 from the openoffice.org weebsite. I followed the instructions precisely and everytime ended up in the same error message - 'error: can't create transaction lock on /var/lib/rpm/.rpm.lock (Permission denied)'. I am using Fedora 13.
View 2 Replies
View Related
Mar 25, 2010
When i connect windows server 2003 from ubuntu these error displayed .When i installing the tsclient, by executing these following command from a Terminal window:
sudo apt-get install tsclient
When i run these command the following error displayed.
E: Could not get lock /var/lib/dpkg/lock - open (11 Resource temporarily unavailable)
E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?
View 1 Replies
View Related
Sep 14, 2010
I have a HP Pavilion dv4 that is 4 months old. Yesterday it suddenly seemed to restart then once I logged in it turned off. When I tried to turn it on some of the lights came on and the caps lock and num lock started flashing. Since then I have not been able to get it to work correctly.It once seemed to turn on but died again after the login window.I tried to use my live cd but the same thing happened. It started loading once, but then shut down again. Every other time it stayed dead minus the lights
View 1 Replies
View Related
Jun 12, 2011
I recently installed Ubuntu 11.04 on an old Sony Vaio laptop. I was following some of the steps here..[url]
The step "Enable Full DVD Playback(Dual Layer DVD Support)" did not finish correctly doh and now I can't use 'sudo apt-get' for anything or the software center or using the 'Update Manager' does not work.
The update manger says it may be caused by an update not finishing correctly which sounds correct as explained above. The apt-get command gives me back the following....'Could not get lock /var/lib/dpkg/lock resource temporarily unavailable' 'unable to lock administration directory /var/lib/dpkg is another process using it?'
I tried the obvious restart but that hasn't worked.
View 6 Replies
View Related
Feb 25, 2010
my problem is the terminal:
E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/) , are you root?
View 2 Replies
View Related
Apr 3, 2010
I have pidgin2.5.2. I want to install pidgin2.6.6.How can I do that?E: Could not get lock /var/lib/dpkg/lock - open (11 Resource temporarily unavailable)E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?
View 1 Replies
View Related
May 2, 2010
There is a very strange problem I've been having. When I enable either Caps Lock or Num Lock the media controls on my keyboard cease to work. I have Googled this one to death but found nothing. This problem existed in Xubuntu 9.10 and now still exists in Xubuntu 10.04. The keyboard I use is a Logitech Elite Keyboard. I would love to be able to use the Caps Lock and Num Lock without the worry that I am disabling the media controls
View 4 Replies
View Related
May 27, 2010
I have just burned the latest CD using infraRecorder, as per the instructions on this site, however when I boot from this CD, it spends about 5 minutes moving the red balls across my screen, then all of the sudden it just freezes, and my caps and scroll lock lights start to blink. I've had a look in the forums already but there's nothing about this happening on Boot of the live CD.
View 6 Replies
View Related
Jun 23, 2010
I'm wondering why the num lock doesn't work in Ubuntu anymore? When you press the "num lock" key, you're supposed to be able to input the numbers along with + - * / and decimal point. When I press num lock and try typing numbers, nothing happens.
I've done a google search and this is a well known problem that nobody has fixed. In Windows it's never a problem.
Seems such a shame that the great Ubuntu and Linux are so good for stability and speed, but can't get a simple num lock working.
View 9 Replies
View Related
Oct 31, 2010
I am having a very annoying problem with my laptop.I am experiencing many freezes.When my laptop freezes, it shows the caps lock and scroll lock lights blinking.At first I thought it was a problem with flash (here is original thread: URL... )In the original thread, I thought the freeze's were being caused by the flashplayer, but it apparently isn't the case.The last time I experienced the freeze, I was playing around with the compiz desktop effects.
View 4 Replies
View Related
Mar 2, 2011
If multiple threads operate on a single shared resource, we can lock it using pthread_mutex_lock. Uptill that it is fine, but why again pthread_cond_wait?
int shared=0; // global
.
.
// Thread 1
pthread_mutex_lock(&mutex);
shared=1;
pthread_mutex_unlock(&mutex);
When thread1 invokes the mutex lock, no other threads can access it in parallel. So why again and what for we use, pthread_cond_wait( ).
View 2 Replies
View Related
Aug 16, 2010
Lately I sometimes get the error message:
Code:
E: Could not get lock /var/cache/apt/archives/lock - open (11: Resource temporarily unavailable)
E: Unable to lock the download directory
when I try to update. I get this using both the Update Manager or using
Code:
sudo apt-get update
sudo apt-get upgrade
View 6 Replies
View Related
Apr 5, 2010
When i log in as root, and try to click the lock screen button, lock screen doesnt work? Is it disabled by default?is there anyway to lock screen when logged in as root
View 6 Replies
View Related
Oct 13, 2010
Can I change the Caps Lock key to Control and still keep the on/off nature of Caps Lock? I've checked into using xmodmap and seem to have hit a dead end. Many people want to swap them, but they also want to swap the way they work. I'd rather keep my new Control key as an on/off switch for Control.
View 1 Replies
View Related
Jan 3, 2010
I have experienced that the button in my main menu "Lock Screen" does nothing, so I can not lock my screen. What could be the problem? Is there any command in terminal what I could write, so I can see is there an error output or something?
I am using Ubuntu 9.10, GNOME.
View 5 Replies
View Related