Sponsored Content
Top Forums Programming Multi thread data sharing problem in uclinux Post 302397716 by mrhosseini on Tuesday 23rd of February 2010 02:01:51 AM
Old 02-23-2010
thanks,

Quote:
You should really be using mutexes, though.
yes, that was just an example that i used to test the threads behavior.

so the mutexes and any other data that i want to be shared must be defined as volatile, am i right?
This User Gave Thanks to mrhosseini For This Post:
 

8 More Discussions You Might Find Interesting

1. Programming

Multi threading using posix thread library

hi all, can anyone tell me some good site for the mutithreading tutorials, its application, and some code examples. -sushil (2 Replies)
Discussion started by: shushilmore
2 Replies

2. UNIX for Advanced & Expert Users

mmap vs shared memory - which is best for sharing data between applications?

Between mmap and shared memory which is the best method of sharing data between multiple applications, interms of speed? (2 Replies)
Discussion started by: nmds
2 Replies

3. Programming

forking. sharing global data in childs

hi, i want to write a code for forking 3 4 child. n wants that every child process one of the account from global account list. i wrote a program for that, but problem is every child is processing every account in list. what can me done to avoid it. attaching code with it #include <stdio.h>... (2 Replies)
Discussion started by: anup13
2 Replies

4. Solaris

Windows/Solaris data sharing

Hi all, I have a request from Developer team in my compagny, they would like to be able to share data between unix and windows world. 1. We would like to be able to see Unix data from Windows : ?Samba ? 2 We would like to be able to see windows data from Solaris (Mount point) : ?NFS server... (4 Replies)
Discussion started by: unclefab
4 Replies

5. Shell Programming and Scripting

data sharing between process

hi ! i want to make 2 c prog such tht if i give an input in 1st prog then i can use tht input in 2nd. so over all i want to do data sharing between process using files. plz give me suggestions how can i achieve this ? thanks ya! (2 Replies)
Discussion started by: Sgupta
2 Replies

6. Shell Programming and Scripting

Multi thread shell programming

I have a unix directory where a million of small text files getting accumulated every week. As of now there is a shell batch program in place which merges all the files in this directory into a single file and ftp to other system. Previously the volume of the files would be around 1 lakh... (2 Replies)
Discussion started by: vk39221
2 Replies

7. UNIX for Dummies Questions & Answers

Cross-compiling libiconv for uclinux

Hi everyone, I want to cross-compile libiconv for uclinux to create a static library. I use the following command : ./configure --enable-static --disable-shared --build=i686-pc-linux-gnu --host=nios2-unknown-linux-gnu --prefix=/home/captain/Programs/nios2-linux/uClinux-dist/staging/usr... (2 Replies)
Discussion started by: moganesh
2 Replies

8. Shell Programming and Scripting

Multi thread awk command for faster performance

Hi, I have a script below for extracting xml from a file. for i in *.txt do echo $i awk '/<.*/ , /.*<\/.*>/' "$i" | tr -d '\n' echo -ne '\n' done . I read about using multi threading to speed up the script. I do not know much about it but read it on this forum. Is it a... (21 Replies)
Discussion started by: chetan.c
21 Replies
MTX_POOL(9)						   BSD Kernel Developer's Manual					       MTX_POOL(9)

NAME
mtx_pool, mtx_pool_alloc, mtx_pool_find, mtx_pool_lock, mtx_pool_lock_spin, mtx_pool_unlock, mtx_pool_unlock_spin, mtx_pool_create, mtx_pool_destroy -- mutex pool routines SYNOPSIS
#include <sys/param.h> #include <sys/lock.h> #include <sys/mutex.h> struct mtx * mtx_pool_alloc(struct mtx_pool *pool); struct mtx * mtx_pool_find(struct mtx_pool *pool, void *ptr); void mtx_pool_lock(struct mtx_pool *pool, void *ptr); void mtx_pool_lock_spin(struct mtx_pool *pool, void *ptr); void mtx_pool_unlock(struct mtx_pool *pool, void *ptr); void mtx_pool_unlock_spin(struct mtx_pool *pool, void *ptr); struct mtx_pool * mtx_pool_create(const char *mtx_name, int pool_size, int opts); void mtx_pool_destroy(struct mtx_pool **poolp); DESCRIPTION
Mutex pools are designed to be used as short term leaf mutexes; i.e., the last mutex one might acquire before calling mtx_sleep(9). They operate using a shared pool of mutexes. A mutex may be chosen from the pool based on a supplied pointer, which may or may not point to any- thing valid, or the caller may allocate an arbitrary shared mutex from the pool and save the returned mutex pointer for later use. The shared mutexes in the mtxpool_sleep mutex pool, which is created by default, are standard, non-recursive, blockable mutexes, and should only be used in appropriate situations. The mutexes in the mtxpool_lockbuilder mutex pool are similar, except that they are initialized with the MTX_NOWITNESS flag so that they may be used to build higher-level locks. Other mutex pools may be created that contain mutexes with dif- ferent properties, such as spin mutexes. The caller can lock and unlock mutexes returned by the pool routines, but since the mutexes are shared, the caller should not attempt to destroy them or modify their characteristics. While pool mutexes are normally leaf mutexes (meaning that one cannot depend on any ordering guarantees after obtaining one), one can still obtain other mutexes under carefully controlled circumstances. Specifically, if one has a private mutex (one that was allocated and initialized by the caller), one can obtain it after obtaining a pool mutex if ordering issues are carefully accounted for. In these cases the private mutex winds up being the true leaf mutex. Pool mutexes have the following advantages: 1. No structural overhead; i.e., they can be associated with a structure without adding bloat to it. 2. Mutexes can be obtained for invalid pointers, which is useful when one uses mutexes to interlock destructor operations. 3. No initialization or destruction overhead. 4. Can be used with mtx_sleep(9). And the following disadvantages: 1. Should generally only be used as leaf mutexes. 2. Pool/pool dependency ordering cannot be guaranteed. 3. Possible L1 cache mastership contention between CPUs. mtx_pool_alloc() obtains a shared mutex from the specified pool. This routine uses a simple rover to choose one of the shared mutexes man- aged by the mtx_pool subsystem. mtx_pool_find() returns the shared mutex associated with the specified address. This routine will create a hash out of the pointer passed into it and will choose a shared mutex from the specified pool based on that hash. The pointer does not need to point to anything real. mtx_pool_lock(), mtx_pool_lock_spin(), mtx_pool_unlock(), and mtx_pool_unlock_spin() lock and unlock the shared mutex from the specified pool associated with the specified address; they are a combination of mtx_pool_find() and mtx_lock(9), mtx_lock_spin(9), mtx_unlock(9), and mtx_unlock_spin(9), respectively. Since these routines must first find the mutex to operate on, they are not as fast as directly using the mutex pointer returned by a previous invocation of mtx_pool_find() or mtx_pool_alloc(). mtx_pool_create() allocates and initializes a new mutex pool of the specified size. The pool size must be a power of two. The opts argument is passed to mtx_init(9) to set the options for each mutex in the pool. mtx_pool_destroy() calls mtx_destroy(9) on each mutex in the specified pool, deallocates the memory associated with the pool, and assigns NULL to the pool pointer. SEE ALSO
locking(9), mutex(9) HISTORY
These routines first appeared in FreeBSD 5.0. BSD
February 6, 2010 BSD
All times are GMT -4. The time now is 07:40 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy