LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-03-2004, 07:54 PM   #1
feetyouwell
Member
 
Registered: Dec 2003
Location: NC, US
Distribution: Novell Linux Eval (2.6.5)
Posts: 240

Rep: Reputation: 30
how to claim array on shared memory


supposed i have an array called abc[5], and i have created a shared memory with id as shmid
is this the correct way to put abc[5] onto shared memory?

abc = shmat(shmid, 0, 0)

thanks
 
Old 11-04-2004, 09:31 AM   #2
rajesh_b
Member
 
Registered: Sep 2004
Location: Hyderabad.
Posts: 83

Rep: Reputation: 15
I think that can be done by the following way.

if((shmid= shmget(SHMKEY,((sizeof(int))*5),IPC_CREAT0666))<0)
{
//error
}
if((arr=(int *)shmat(shmid,(char *)0,0))==(int *)-1)
{
// error
}

then u can use it as
a[i]=1;
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Create clustering of two linux with shared array manstt Linux - Enterprise 2 11-23-2005 02:13 AM
is shared memory expandable in memory size? Thinking Programming 4 08-16-2005 09:57 AM
c + shared memory dilberim82 Programming 3 03-07-2005 07:49 PM
How to allocate memory for a multidimensional array ? indian Programming 12 11-19-2004 03:37 AM
shared memory socket9001 Programming 4 02-06-2004 02:08 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:31 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration