Sponsored Content
Full Discussion: Variables betwen pthreads ?
Top Forums Programming Variables betwen pthreads ? Post 302096781 by !_30 on Saturday 18th of November 2006 08:01:30 AM
Old 11-18-2006
Variables betwen pthreads ?

I have a doubt .. ( maybe I don't know ..)

Let's say , we got the folowing example ( to understand better what I mean ).

We got two POSIX threads ( pthreads ) , one receives some strings and creates a menu ( for that strings , scrollable menu ) , and another one check's to see if it has to scroll the menu , or scroll down some strings.

I mean , the menu with strings is created in one pthread ( lets say it 1 ) , and simultanous checking if to scroll down strings or even menu is done is pthread 2 . How can pthread 2 know the location ( I mean pointer ) of the menu & window used in pthread 1 ? I mean a menu and a window are created in pthread 1 and fill out , at regular intervals , but I want pthread 2 to local variables used in pthread 1 to..

something like :

Code:
 p1 = pthread_create(&thread1, NULL , Check, NULL);
 p2 = pthread_create(&thread2, NULL , Receive ,NULL);

and ..

void *Check()
{
int c;

 if (c = wgetch(wind)) == KEY_DOWN )
      {
                menu_driver(menu, REQ_DOWN_ITEM);
                wrefresh(wind)
	break;
}

...
}

and ..

void *Receive()
{
WINDOW *wind;
MENU *menu;
ITEM *item;

< create window  wind  and menu   menu >

}

What I want ? I want Check void to use wind and menu from Receive .. Can I do this ( multithreading ) ?


Thanks in advance ! Smilie
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

PThreads

Can anyone explain me how to use pthread_key_create() , pthread_setspecific(), pthread_getspecific() and pthread_key_delete () routines in pthreads. Kindly state by an example. (3 Replies)
Discussion started by: S.P.Prasad
3 Replies

2. Programming

pthreads

Does any one no of some good web site which will explain about how to program using pthreads in a UNIX enviroment? (6 Replies)
Discussion started by: fishman2001
6 Replies

3. Programming

pthreads

howcome that pthtreads spawn 2 extra processes? I'm kind of new with pthreads but fork() did not act like this. Anyone who can give me a technical explanation of what happends with mother / daughter processes? Best regards Esaia. (2 Replies)
Discussion started by: Esaia
2 Replies

4. Programming

PThreads

I have created a thread program, it is attached. My problem is that I need to loop this program multiple times, and basically reset everything including the threads created previously. I try to loop the program, the first run is fine, as always, but the second run of the program, the initialize... (0 Replies)
Discussion started by: justgotthis
0 Replies

5. UNIX for Dummies Questions & Answers

Question on Pthreads

How to give superuser privileges while setting the attributes like pthread_attr_setschedpolicy( )?? Even with normal user mode ,it is working fine for me.But in man pages, they have specied that to set the scheduling policy as SCHED_FIFO, the process should have superuser privileges. (0 Replies)
Discussion started by: yashavant.a
0 Replies

6. HP-UX

pthreads

Hi! I'm linking my hpux code using -lpthread (gcc), yet it references libpthread_tr.1, the debug version of the pthread lib. How do I force it to use pthreads? Thanks, :) (3 Replies)
Discussion started by: zackz
3 Replies

7. Programming

Problem with pthreads

hi i have a code: I found that after exiting from child thread memory isn't freed. I commented everything which is "some actions" here, so thread's function contains only two lines. But it doesn't help. What do I do wrong? Thanks a lot (3 Replies)
Discussion started by: sery0ga
3 Replies

8. UNIX for Advanced & Expert Users

Pthreads-Conditional variables

Hello, consider a bunch of threads which want to execute a while loop in parallel but after each iteration of while loop, we need a synchornization.That is, we have a global count varibale which is equal to zero at beginig of each iteration and at the end of each iterartion this variable... (0 Replies)
Discussion started by: Behnaz
0 Replies

9. Shell Programming and Scripting

redirecting to stdout in betwen command

can anyone help me in making singleline command for Capital Letters are folders ,small letter are files X,Y,Z are subfolders of A as shown below A - X,Y,Z Folder X has three files a.txt,b.txt,c.txt similarly Y,Z. as shown below X- a.txt,b.txt,c.txt Y- a.txt,b.txt,c.txt Z-... (4 Replies)
Discussion started by: phoenix_nebula
4 Replies

10. Shell Programming and Scripting

Shell script to compare ,diff and remove betwen 2 files

Hi Friends Need your expertise. Command to check the difference and compare 2 files and remove lines . example File1 is master copy and File2 is a slave copy . whenever i change, add or delete a record in File1 it should update the same in slave copy . Can you guide me how can i accomplish... (3 Replies)
Discussion started by: ajayram_arya
3 Replies
menu_win(3X)															      menu_win(3X)

NAME
menu_win - make and break menu window and subwindow associations SYNOPSIS
#include <menu.h> int set_menu_win(MENU *menu, WINDOW *win); WINDOW *menu_win(const MENU *menu); int set_menu_sub(MENU *menu, WINDOW *sub); WINDOW *menu_sub(const MENU *menu); int scale_menu(const MENU *menu, int *rows, int *columns); DESCRIPTION
Every menu has an associated pair of curses windows. The menu window displays any title and border associated with the window; the menu subwindow displays the items of the menu that are currently available for selection. The first four functions get and set those windows. It is not necessary to set either window; by default, the driver code uses stdscr for both. In the set_ functions, window argument of NULL is treated as though it were stsdcr. A menu argument of NULL is treated as a request to change the system default menu window or subwindow. The function scale_menu returns the minimum size required for the subwindow of menu. RETURN VALUE
Routines that return pointers return NULL on error. Routines that return an integer return one of the following error codes: E_OK The routine succeeded. E_SYSTEM_ERROR System error occurred (see errno). E_BAD_ARGUMENT Routine detected an incorrect or out-of-range argument. E_POSTED The menu has already been posted. E_NOT_CONNECTED No items are connected to the menu. SEE ALSO
curses(3X), menu(3X). NOTES
The header file <menu.h> automatically includes the header file <curses.h>. PORTABILITY
These routines emulate the System V menu library. They were not supported on Version 7 or BSD versions. AUTHORS
Juergen Pfeifer. Manual pages and adaptation for new curses by Eric S. Raymond. menu_win(3X)
All times are GMT -4. The time now is 05:47 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy