General :: Pthreads - Executing Two Different Functions Simultaneously

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


ADVERTISEMENT

General :: Executing A Script In Multiple Subdirectories Simultaneously?

Sep 14, 2010

i'd like to execute in several subdirectories that all have the same name, but I don't want to have to change into each subdirectory (there are hundreds) to execute the script. All the subdirectories have the same name ("final_alignments"), but are located in parent directories with different names. All these parent directories are in the same "super parent" directory. I've tried to do this using "for/do" and "find" but no luck so far.

View 8 Replies View Related

General :: Deleted The /etc/rc.d/functions Folder And Functions.d Script And Turned Arch Machine Into A Brick?

Mar 19, 2011

None of my daemon scripts work now, and the startup process displayed errors. Should I reinstall the OS and start from scratch, or is there a way to recover these files? Is there a way to rebuild the files I deleted?

View 2 Replies View Related

General :: Pthreads - Structure Can Be Returned With Value

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

Programming :: Define Functions Within Other Functions In C++?

Mar 11, 2010

Is it possible to define functions within other functions in C++? I know it is the case in other languages.

View 2 Replies View Related

Programming :: Preemption And Scheduling Of Pthreads

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

Programming :: Suspend Pthreads Without Condition

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

Programming :: Pthreads Return Value Valid Or Not

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

Programming :: Segfault In Program Using Pthreads

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

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 View Related

Programming :: Is Popen Thread Safe Via Pthreads?

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

Programming :: Related To Pthreads And Timers In POSIX Standard

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

General :: Two Networks Cannot Be Accessed Simultaneously

Mar 14, 2011

I have two networks on a server. One being my internal network, and the other being an external IP address. This is on Debian Lenny. Here is my /etc/network/interfaces file:

I can reboot my system and sometimes eth1 is accessible from SSH, and other times eth0 is accessible. Then sometimes eth1 will just stop being pingable alltogether. This is a fairly fresh install of Debian, and the only thing I have running is VMWare Server 2.0, bridged to both of my network connections.

Here is what my route looks like:

View 1 Replies View Related

General :: Utility Available For Copy One HDD To Two More Simultaneously?

Feb 6, 2010

I want to copy data from one source drive to three or more destination drive simultaneously. I tried with dd command. But it copy entire Hard disk. Its take long time to copy entire disk. i need the utility or software to copy one source to multi destination simultaneously and fast manner

View 3 Replies View Related

General :: Functions Of The Tar Utility?

Apr 30, 2010

What are the functions of the tar utility?

View 9 Replies View Related

General :: Windows 7 - Can Two Users Simultaneously Share One Pc

Feb 9, 2010

It's easy to have multiple user accounts on one computer and even switch between accounts without logging off. It is also possible to have more than one display connected to a single computer. Is it possible to have one multi-core computer be used simultaneously by two users in their own accounts? Is there specific hardware required (to allow keyboard and mouse distinction for each user) and software configuration?

I know you can setup remote connections on windows that allow you to open and use a second user account without bothering the first user, but how about working locally on the same machine, essentially removing the network delay of remote desktops? What OS supports this? Linux Ubuntu? Windows 7?

View 4 Replies View Related

General :: Work Simultaneously With Windows 7 And Redhat?

Feb 8, 2011

how to change the screen from windows to linux very easily just like in windows (whenever u press alt+tab to switch between two or more windows).

View 8 Replies View Related

General :: Configure And Run IPSEC Simultaneously On Same Server?

Apr 8, 2010

I had configured OpenVpn on my Server.Is it possible to Configure and run IPSEC simultaneously on the Same server?

View 2 Replies View Related

General :: Install More Than One Machine Simultaneously With Kickstart?

Nov 18, 2010

Is it possible to install more than one machine simultaneously with kickstart? I need to install 15 machines.

View 2 Replies View Related

General :: Unable To Use Functions With Bash

Dec 24, 2009

Code:

#!/bin/bash
#Functions
CallFunct() {
functio()

[code]....

When I try to run the current code, it stops on the bracket after functio() in CallFunct(). The only way I could get this to run was by removing CallFunct and just calling functio.

View 3 Replies View Related

General :: Running A Program In Multiple Subdirectories Simultaneously

Jul 8, 2011

Performing commands in multiple subdirectories simultaneously. I'd like to run a program I've copied into every subdirectory which takes *.in files in the current directory as input files. I can find the program, but how do I tell it to run when I've found it?

View 1 Replies View Related

General :: Is It Safe To Mount Encfs Via Nfs On Several Machines Simultaneously

Mar 25, 2010

There are some encfs folders with private data on the server and all data is exported via nfs to all other omputers in the house.I can mount the encfs folders on another computer (using encfs command) to work with the data, but I never dared to mount it on more than one computer simultaniously, because I fear the encrypted data might get corrupted if more than one computer mount and access it at the same time.

So I want to ask about your experience: Is it safe to mount an encfs folder on several computers at the same time? All computers use "hard" and "sync" as nfs mount options to minimize risks of data loss. But can I access the folders simultaniously, or do I risk corrupting the encfs encryption and lose everything?

View 2 Replies View Related

General :: 2 Disks Failed Simultaneously On A RAID 5 Array?

Apr 15, 2011

I have a home server running Openfiler 2.3 x64 with 4x1.5TB software RAID 5 array (more details on the hardware and OS later). All was working well for two years until several weeks ago, the array failed with two faulty disks at the same time. Well, those thing could happen, especially if one is using desktop-grade disks instead of enterprise-grade ones (way too expensive for a home server). Since is was most likely a false positive, I've reassembled the array:

Code:

# mdadm --assemble --force /dev/md0 /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1
mdadm: forcing event count in /dev/sdb1(0) from 110 upto 122
mdadm: forcing event count in /dev/sdc1(1) from 110 upto 122

[code]....

Right. Once is just a coincident but twice in such a sort period of time means that something is wrong. I've reassembled the array and again, all the files were intact. But now was the time to think seriously about backing up my array, so I've ordered a 2TB external disk and in the meantime kept the server off. When I got the external drive, I hooked it up to my Windows desktop, turned on the server and started copying the files. After about 10 minutes two drives failed again. I've reassembled, rebooted and started copying again, but after a few MBs, the copy process reported a problem - the files were unavailable. A few retried and the process resumed, but a few MBs later it had to stop again, for the same reason. Several more stops like those and two disks failed again. Looking at the /var/log/messages file, I found a lot of error like these:

Quote:

Apr 12 22:44:02 NAS kernel: [77047.467686] ata1.00: configured for UDMA/33
Apr 12 22:44:02 NAS kernel: [77047.523714] ata1.01: configured for UDMA/133
Apr 12 22:44:02 NAS kernel: [77047.523727] ata1: EH complete

[code]....

The motherboard is Gigabyte GA-G31M-ES2L based on Intel's G31 chipset, the 4 disks are Seagate 7200.11 (with a version of a firmware that doesn't cause frequent data corruption).

View 4 Replies View Related

General :: Multiple Nic Cards Rhel5 Cannot Be Access Simultaneously?

Dec 18, 2010

I installed 2 nic cards in my pentium 4 computer running rhel5 to be used as a proxy server and connect 2 computers in each network card for testing . The problem is I cannot ping or use the 2 cards simultaneously . One must be deactivated for the other to be ping . The Network configuration panel indicate both card status as active but i can only ping the first to be activated . I have already set onboot=yes to both cards but still the same result after restarting . The nic cards are onboard - Realtek RTL8139 and pci -3com 3c905b.

View 4 Replies View Related

General :: Change The Signature Of All The Functions In Scripts?

Mar 23, 2010

I was trying to write a script to change the signature of the all the methods in a set of scripts.. here is a sample of the same :

old signature :

methodname()
{
method-body
}

New signature:

function methodname
{
method-body
}

That is i need to insert "function" keyword in front of the methodname and remove the () after the methodname.

View 4 Replies View Related

General :: Script Has 5 Functions But Exits Only After 2nd Function?

Jan 25, 2011

Quote:
logcountfunction()
{
awk ' {
# when executing the script pass the logfile as parameter on the command prompt with the name of the file
#export file_name= "&1"

[Code]....

my problem is that when i execute this script only the first two functions are being called.once the DBcounttry_finalnofunc() is done ,the script exits.The rest of the functions are not being called.

View 1 Replies View Related

General :: Meaning And Functions Of Shell Symbols?

Mar 16, 2011

In shell scripting, what do or what does this symbol do or mean ? "."(octet), ";" (semicolon)? Would really like to know? Cause I saw a written script if [ -f /etc/file ];then. . /etc/file. Wondering, the "." is meant to be source, so is "." the same thing as "source" ?

View 2 Replies View Related

General :: Windows - Resize An Image To Multiple Resolutions Simultaneously?

Aug 22, 2011

I am looking for software (Windows or Linux) that can do the following: Resize one image to several provided sizes. Detects the type of the pic­ture (wide, nor­mal) and does the resize based on that. What I mean by that is that it should not break the image by shrinking it more in one direction then in the other so it looks weird. The purpose of this is my Blog. If I want to give my readers a wallpaper, I want to give them several options for the sizes so they can have it in their own preferred screen resolution. The image must however keep its original aspect ratio.

View 2 Replies View Related

General :: Check The Referenced Functions In A Executable Through Command?

Oct 20, 2010

Is there any command that can check the referenced functions in a executable?

View 1 Replies View Related

General :: Use Inode Hook Functions(inode_alloc_security And Inode_free_security)?

Mar 4, 2010

how to use inode hook functions(inode_alloc_security and inode_free_security)?

View 1 Replies View Related







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