How to use shared memory as an array of pointers?
Hi,
Can we use the pointer returned by "void** ptr = (void * *)shmat();" for accessing the elements in array fashion?
I have a pointer to pointer to struct - an array of pointers & I want to access the elements by using array notation of ptr[index].
But, when I do so, my process crashes with SSEGV.
My code is somewhat as below:-
size_t size = nSize*sizeof(void *);
key_t key = 90000;
int id = shmget(key,size,0777 | IPC_CREATE);
void** ptr = (void**)shmat(id,(void*)0,0777 | SHM_SHARE_MMU);
memset(ptr,0,size);
void* tmpPtr = ptr[100]; // this line causes crash.I was trying to do this on the basis of following code, which uses malloc & works fine:-
uht->t = (void **)malloc(nSize*sizeof(void *));
pUHT_ITEM curr_item = (pUHT_ITEM)uht->t;
How can I achieve this?
Please help. Thanks.
Message was edited by:
grbSunUser
After debugging the program using dbx, I found that after certain specific index, I get an error of "dbx: cannot access address 0xfd032000", if I do "print suht->t[51200]".
What I did is that I created shm segment of size = 50000 * (sizeof(viod*))
This turns out to be 200084.
By doing step by step print of each index in this shm segment, I reached upto the index of 51199. When I did "print suht->t[51199]" in dbx, I got "suht->t[51199] = (nil)", means this was accessible location.
But, when I tried "print suht->t[51200]", I got an error of "cannot access...".
I think this is index from which, if process tries to access, will cause crash.
How are these numbers related? Should I not do "50000 * sizeof(void*)"?
Similar Messages
-
Using Shared Memory in LabVIEW
I'm trying to use shared memory with LabVIEW. Can I use it, a DLL in C with LabWIEW for use shared Memory?
Lidia,
Check these out (for memory mapping):
http://exchange.ni.com/servlet/ProcessRequest?RHIVEID=101&RPAGEID=135&HOID=5065000000080000006A1D0000&UCATEGORY_0=_318_&UCATEGORY_S=0&USEARCHCONTEXT_QUESTION_0=build+cvi+shared+dll&USEARCHCONTEXT_QUESTION_S=0
http://exchange.ni.com/servlet/ProcessRequest?RHIVEID=101&RPAGEID=135&HOID=5065000000080000005BC10000&UCATEGORY_0=_49_%24_6_&UCATEGORY_S=0&USEARCHCONTEXT_QUESTION_0=Communicating+Between+Built+LV+App&USEARCHCONTEXT_QUESTION_S=0
But in general you don't need to use this when you use dll's. It is used to
share data between different processes. If you need LabVIEW data in a dll,
try to pass it as a pointer to an array, or as a string pointer.
Regards,
Wiebe.
"lidia" wrote in message
news:506500
[email protected]..
> I'm trying to use shared memory with LabVIEW. Can I use it, a DLL in C
> with LabWIEW for use shared Memory? -
How to use abap memory in global class
Hi experts,
I want to know how to use abap memory in global class. when i try write export and import statement its showing
error is export statement does not support in object oriented concept.
Thanks
Ramesh ManoharanHi Ramesh,
Export and import statements were not allowed to use in classes. Create a global variable in public section of that class of type of export parameter.Then pass value to the global variable of class by calling that class.
by
Prasad GVK. -
How to use shared parameter on request set
Hi
I have a request set with two stages
First stage contains From Date and To date where i have named the shared parameter as StartSP and EndSP
i have to use these shared parameter in one of the query in next stage where my Type is SQL Statment and i have these two date fields From date and To date in next stage as well where i am able to retirve the values from previous stage
based on these values i need to get the name in next parameter where my Type is SQL Statment
select name from tablename where '02-MAR-09' > =start_Date and '29-MAR-09' <=end_Date
I have written SQL as
select name from tablename where StartSP > =start_Date and EndSP <=end_Date but it throws an error.
I need the values of 02-Mar-09 and 29-Mar-09 from StartSP and EndSP
Appreciate if any one has idea about this.hi user;
please check:
http://download-west.oracle.com/docs/cd/A60725_05/html/comnls/us/fnd/repset04.htm
http://download-east.oracle.com/docs/cd/A60725_05/html/comnls/us/fnd/10gch609.htm
Also you can check this search:http://www.google.com.tr/search?hl=tr&source=hp&q=How+to+use+shared+parameter+on+request+set+&meta=&aq=f&oq=
Hope it helps
Regard
Helios -
How to use shared variables?
Hello..
Can anybody please guide me in using shared variables... I'm learning LabVIEW 8.5.... But did not understand how to use shared variables... I tried to read web pages regarding shared variables but got confused.... So anyone can please help me...?
Thanks for any help from you...You will have to give us the whole picture. What is your client computer; a PAC, desktop etc? What are you running on the client computer; a VI or an executable? Where are you going to deploy your library? On the host machine or the client machine?
If I assume that you are running a VI on the client machine and are depolying the library on the host, all you have to do is to create another shared variable and bind it to the variable on the host machine. You can do this by checking the Bind to Source option when creating the variable and browsing to the network item in options. Be sure to have the library deployed on the host side before you attempt to do this otherwise you won't be able to find the variable.
Adnan Zafar
Certified LabVIEW Architect
Coleman Technologies -
Hi folks,
This the first time I use shared memory and my question is:
Does shmat function attache the segment to the same address in diffrent procsses, in anther word can I use the same pointer in process A and B?
ThanksThe issue of alignment is rather tricky.
shmat(2) may perfectly return you misaligned address, so I'd consider using memory-mapped files instead.
mmap(2) returns page-aligned memory (unless you specify MAP_FIXED and some weired first parameter), so you may rely further on the compiler to do the alignment for you... -
Short Dump TSV_TNEW_PAGE_ALLOC_FAILED while using shared memory objects
Hi Gurus,
We are using shared memory objects to stor some data which we will be reading later. I have implemented the interfce IF_SHM_BUILD_INSTANCE in root class and using its method BUILD for automatic area structuring.
Today our developments moved from dev system to quality system, and while writing the data into the shared memory using the methods ATTACH_FOR_WRITE and DETACH_COMMIT in one report. We started getting the run time error TSV_TNEW_PAGE_ALLOC_FAILED.This is raised when the method DETACH_COMMIT is called to commit the changes in the shared memory.
Everyhting works fine before DETACH_COMMIT. I know that it is happening since the program ran out of extended memory, but I am not sure why it is happening at DETACH_COMMIT call. If excessive memory is being used in the program, this run time error should have been raised while calling the ATTACH_FOR_WRITE method or while filling the root class attributes. I am not sure why it is happening at DETACH_COMMIT method.
Many Thanks in advance.
Thanks,
RaveeshHi raveesh,
as Naimesh suggested: Probably system parameter for shared memory area is too small. Compare the system parameters in devel and QA, check what other shared memory areas are used.
Regarding your question, why it does not fail at ATTACH_FOR_WRITE but then on DETACH_COMMIT:
Probably ATTACH_FOR_WRITE will set an exclusive write lock on the shared memory data, then write to some kind of 'rollback' memory and DETACH_COMMIT will really put the data into shared memory area and release the lock. The 'rollback' memory is in the LUW's work memory which is much bigger as the usual shared memory size.
This is my assumption - don't know who can verify or reject it.
Regards,
Clemens -
How to use SAP Memory analyser in CE7.1 EHP1
Hi All,
Please Can you provide proper link to know how to use SAP Memory analyser in CE7.1 EHP1.
It is urgent .
Regards
MaheshProblem solved.
-
I want to used shared memory in LabVIEW. I think I can do it using a DLL in C.
I think I can use shared memory with a DLL in C. But, Can I use some utility included in LabVIEW to do that, without include my DLL?
Jorge M. wrote:
> Hello,
>
> here's the info. It works.
>
> http://exchange.ni.com/servlet/ProcessRequest?RHIVEID=101&RPAGEID=135&HOID=5065000000080000006A1D0000&UCATEGORY_0=_318_&UCATEGORY_S=0&USEARCHCONTEXT_QUESTION_0=build+cvi+shared+dll&USEARCHCONTEXT_QUESTION_S=0
Another one:
http://exchange.ni.com/servlet/ProcessRequest?RHIVEID=101&RPAGEID=135&HOID=5065000000080000005BC10000&UCATEGORY_0=_49_%24_6_&UCATEGORY_S=0&USEARCHCONTEXT_QUESTION_0=Communicating+Between+Built+LV+App&USEARCHCONTEXT_QUESTION_S=0
Rolf Kalbermatter
Rolf Kalbermatter
CIT Engineering Netherlands
a division of Test & Measurement Solutions -
Hello,
I am trying to use LabVIEW 2010 to control 4 Watlow temperature controllers on one COM port. 3 are Model 96 and 1 is an EZ zone controller. Each controller has a unique modbus address, and I am trying to read from and write to individual registers (such as closed loop setpoint) using shared variables. I am getting return data when reading (although the data appears to be invalid), but am unable to change the value in the register by writing. How can I be sure that the Modbus server is sending commands to the correct controller?
Chuck
Solved!
Go to Solution.Peter,
Thanks for the reply. I have actually solved that problem. I realized that the Modbus server address has to be the same as the controller's Modbus address.
I have, however, run into another problem. Perhaps you could help me with that. I have a system with 4 Watlow controllers, 3 are series 96 controllers, one is PID only and 2 are ramping. The 4th controller is an EZ zone. I am using RS485 for communications and the controllers are all wired in parallel for communications and power.
I have set up 2 Modbus servers for 2 of the controllers.
This is the first I have ever worked with Modbus based communications. I have successfully programmed using the Modbus read/write VIs, and am wanting to move to shared variables. My questions right now revolve around addressing, Modbus I/O servers and COM ports. Specifically, at this point, I know the addresses need to match up between the server and the slave device (Watlow controller in my case), how many servers can I create and use on one COM port? If the number is limited, is there a way I can specify an address that I want the server to talk to? Will the broadcast mode work to request data values from the controllers?
I'd appreciate any information you can help me with, or if you could point me to some sort of concise 'How-To' for Modbus communication.
Thanks.
Chuck -
How to use shared variables with native c programs
Hello
What is the way to use shared variables with native c programs?
I have a c/c++ program that uses the NIDAQmx C-API to perform measurements. Now I want to communicate to a LabVIEW program via shared variables.
Is there a C-API for shared variables as there is for the NIDAQmx functionality? Where can I find further documentation? The document "Using the LabVIEW Shared Variable" mentions that one "can read and write to shared variables in ANSI C", but there are no hints about how and where to look.
Thanks in AdvanceHi user42,
with CVI 8.0, you cannot create or configure shared variables. However, you can read or write to an already configured LabVIEW 8.x shared variable from CVI using the DataSocket API.
In order to do this you need to have and DataSocket 4.3 or higher installed.
Here's a forum post about using the DataSocket functions a LabVIEW Shared Variables:
http://forums.ni.com/ni/board/message?board.id=180&message.id=24569&requireLogin=False
With CVI 8.1 and Measurement Studio 8.1 it's possible to use Shared Variables via the Network Varaiable Library (check out the end of the "Network-Published Shared Variable" section within the "Using the LabVIEW Shared Variable" documentation and the following link).
Datasocket with LabWindows/CVI and LabVIEW Real-Time:
http://digital.ni.com/public.nsf/allkb/CC4343488413A2F586256E6200099638?OpenDocument
Daniel
NIG -
How to use sharing to find a stolen laptop
I saw a news story about a guy whose laptop was stolen. He accessed the laptop remotely and watched the activity on it. He finally saw the thief enter his name and address to register on a web site, then he sent the police to that address and they recovered the laptop. (That was a windows machine.) I saw another article - a few months ago - about a stolen Mac laptop that was recovered when the woman who owned it accessed it remotely and used the built-in camera to take a picture of the thief. Cool stuff - which I could not do!
I use a Mac laptop as my only computer, and I travel a lot. If it got stolen, I'd like to be able to access it remotely and try to recover it. I looked at the sharing preferences, and there are ten different options that can be turned on or off. And the descriptions of each of those options are very minimal.
After reading the news stories about people who recovered their stolen laptops, I'd really like to know how to set up sharing services on my Mac to be able to do the same thing.
Are there any articles or web sites or support notes on the topic of "How to set up and use sharing to recover a stolen Macintosh"? If there are, can you direct me to them? If not, this would a great article or support note for somebody to write.
What sharing services would you turn on? If there are configuration options for those services, how should the options be set? If the computer is stolen, what actions would take to track the computer and try to recover it?that's correct but there are ways around that too (if one knows them). physical access to the computer trumps any safeguards you can put. of course, not every thief would know how to circumvent a firmware password. Still, it's not such a great secret. the method has been discussed many times on this forum for example. I'm not trying to discourage you from buying the software. I just wanted to explain that none of this is foolproof.
-
DB_ACTION_STATNEW - Error - How to increase shared memory in shadow instanc
Hi all,
We are facing the below error in the DB_ACTION_STATNEW phase:
TRACE-INFO: 82: 13 4.822960
TRACE-INFO: 83: [developertra,00000] WHERE TABNAME = :A0; 8 4.822968
TRACE-INFO: 84: [dbntab ,06694] ***LOG BY4=>sql error 604 performing SEL on table DDNTT
TRACE-INFO: 85: 222 4.823190
TRACE-INFO: 86: [dbntab ,06694] ***LOG BY0=>ORA-00604: error occurred at recursive SQL level 1
TRACE-INFO: 87: ORA-04031: unable to allocate 4120 bytes of shared memory ("shared pool","select t.ts#,t.file#,t.block...","Typecheck","seg:kggfaAllocSeg")
TRACE-INFO: 88: 21 4.823211
TRACE-INFO: 89: [dbeh.c ,00000] *** ERROR => missing return code handler 13 4.823224
TRACE-INFO: 90: caller does not handle code 1 from dbntab.c[3718]
TRACE-INFO: 91: ==> calling sap_dext to abort transaction
HALT 20080410111303
We have a physical RAM of 64 GB.
dcecqv1:root > dmesg | more
Apr 10 11:24
$Revision: vmunix: B11.23_LR FLAVOR=perf Fri Aug 29 22:35:38 PDT 2003 $
Memory Information:
physical page size = 4096 bytes, logical page size = 4096 bytes
Physical: 66399504 Kbytes, lockable: 51408244 Kbytes, available: 59648572 Kbytes
From the error message, I feel that I need to increase the shared memory, can you help me how to increase the shared memory now, bcos system is now running in the shadow instance.
Thanks & Regards
SenthilThank you for your mail Shaji.
SQL> show parameter shared_pool_size
ORA-00604: error occurred at recursive SQL level 2
ORA-04031: unable to allocate 4120 bytes of shared memory ("shared
pool","select x.inst_id,x.indx+1,ks...","Typecheck","seg:kggfaAllocSeg")
When I tried to see the shared_pool_size it gives the above error.
Regarding the three log files:
STATNEW.LOG
LISTNEW.LOG
DBSTATNEW.LOG
- I didnot find STATNEW.LOG file in the path /usr/sap/put/log
- supadm> cat DBSTATNEW.LOG
1 ETQ201XEntering upgrade-phase "DB_ACTION_STATNEW" ("20080410111258")
2 ETQ367 Connect variables are set for standard instance access
4 ETQ399 System-nr = '02', GwService = 'sapgw02'
4 ETQ399 Environment variables:
4 ETQ399 dbs_ora_schema=SAPR3
4 ETQ399 auth_shadow_upgrade=0
4 ETQ389 reading file "LISTNEW.LOG" in directory "/usr/sap/put/log".
4 ETQ275 Created SQL-script "EXSTATE.ORA"
4 ETQ275 Created SQL-script "EXSTATC.ORA"
4 ETQ276 Executing SQL-script "EXSTATE.ORA"
4 ETQ001 START time "2008/04/10 11:12:58"
4 ETQ399 ext. env.: DIR_LIBRARY=/usr/sap/SUP/SYS/exe/run
4 ETQ399 ext. env.: LD_LIBRARY_PATH=/usr/sap/SUP/SYS/exe/run:/opt/java1.5/jre/lib/IA64N:/opt/java1.5/jre/lib/IA64N/server:/opt/java1.5/jre/../lib/IA64N
4 ETQ399 2008/04/10 11:12:58: put_execute: (tp) forkpid:2537
4 ETQ002 END time "2008/04/10 11:13:03"
4 ETQ278 Errors during execution of SQL-script "EXSTATE.ORA"
1EETQ203 Upgrade phase "DB_ACTION_STATNEW" aborted with errors ("20080410111303")
supadm>
supadm> tail LISTNEW.LOG
NAME= WTY_OBJNR_INDEX
NAME= WTY_PARTNER_TAB
NAME= WTY_RCLHST
NAME= WTY_RCLOBJ
NAME= WTY_RELOB_TAB
NAME= WTY_RELOB_TAB_TX
NAME= WTY_TABLE_ALV
NAME= WYT2M
tp_exec_dbscript: 1 statement(s) successfully processed.
supadm>
Can u pl help
Thanks
Senthil -
How to use HorizontalList populated with an Array of Image?
Is it possible to populate a HorizontalList with an Array of
Image? I am trying to create a HorizontaList of Images (thumbnails)
using a dynamic method where I put each thumbnails found into an
Array and then indicating to the HorizontalList to use the Array as
the dataProvider. The result is that I just see the ID generated
for each Image.
Since I am controlling the content of the HorizontalList into
the mx:source, I am a bit confused how to use the itemRenderer
property.
Any help will be appreciated since Google don't show a lot of
example/problems like mine at this moment!Hi,
Just set the itemRenderer property to mx.controls.Image and
you should be done. -
How to use Shared secret key(diffie hellman) for encryption n decryption
In my client server program i wanted to encrypt a random key using shared secret key for encryption and decryption with DES. but i'm unable to encrypt it as init() is not takin the shared secret key for encryption. somebody please help. my mail id - [email protected]
You need to post some code because it works for everyone else.
Maybe you are looking for
-
Lançamentos de conhecimento de frete de compras
Pessoal, Estamos implementando um novo software de comércio exterior aqui na empresa, ainda na versão 4.6C. Diferentemente do cenário que temos atualmente para o novo cenário customizamos uma pricing de pedido de compras composta de várias condições
-
How to know the stake amount of both the won and lost opportunities
Hi, I need to create a report. I would like to have a chart related to the last year opportunities. I would like to know in the same reports, the stake amount of the opportunities with the sales stage = Closed/Won, the stake amount of the opportuniti
-
Imported Library - NoClassDefFoundError
Imported Library - NoClassDefFoundError Hi I created a shared library and imported it in my application using orion-application.xml <imported-shared-libraries> <import-shared-library name="amc.common" max-version="1.0"></import-shared-library> </impo
-
Compressor won't submit jobs! Help!!
I have Compressor 3.5 and Final Cut Pro 7 and am trying to send a project to it but after i apply the correct settings to the project to encode to a DVD, (i.e. DVD 90 minutes) for some reason when i try to submit the job the dialog box comes up to na
-
Changing your username... is it possible?
is it possible to change your username for the apple discussions? i know it's not a big deal, but mine's boring... and lars isn't even my name haha