Re: Access to driver memory using c#




"Martin" <zizka@xxxxxxxxxx> wrote in message
news:1145821847.017052.205810@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
| Really is there no other way than unsafe and pointers?
|
| In fact in the hardware there are just input and output buffers and
| some fifos - and I need fast access to both of the types of memories. I
| need only two special types of access to the memory - large data copy
| (memcpy in C) and fast access to one address for read/write.
|
| I'm afraid that Marshal class means lots of copying thus it will slow
| down the access, am I right?
|
| Martin
|

It depends, if you need the unmanaged data to be available as a managed type
(an array of ..), you'll have to copy it somehow.
To do this in C# you have two options, or you can use unsafe code pointers,
or you move the data using Marshal.Copy.
The latter option is your best bet, it's safer, and on V2, it's actually
faster than using unsafe & pointers.
However, if you don't need the unmanaged data to be available as a managed
type, your best option in C# is to access the data directly using unsafe &
pointers.

Willy.



.



Relevant Pages

  • Re: What will be the next MAJOR programming language for commercial use?
    ... This probably means that D is unsafe. ... > less safe, and there is no obvious dividing line between the two. ... It happens that most languages with GC are safe or almost safe. ... > for pointers much less than in, say, C, so one rarely has to deal ...
    (comp.lang.misc)
  • Re: Unsafe lack of pointers in C#?
    ... Pointers can be used in unsafe code blocks from C#. ... Find great Windows Forms articles in Windows Forms Tips and Tricks ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: using classes vs. modules
    ... However, they are typically unsafe, cannot be checked at compile time, and can thus increase the potential for bugs in the code and exploitation. ... I doubt that a beginner would struggle more with pointers than with OOP. ... I've said you do not need to mention bitmap manipulation as I have already mentioned it. ... I used pointers for years in C, which is one of my favorite programming languages beside BASIC-style languages. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: A failing oif C#?
    ... >>> You can infact mark a section of your c# code unsafe and use pointers ... >> How does one mark a section unsafe and have the code before and after ... >> How does one use pointers at all in C#? ... >> subset of that array to be treated as a structure with data members? ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: passing unmanaged pointers
    ... In a member function of the form, ... Cannot convert a managed type to an unmanaged type ... You can see how we can pass both interior pointers as well as native ... this is because native pointers automatically ...
    (microsoft.public.dotnet.languages.vc)

Loading