Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
What are the reasons for restricting Java not to support Pointer Manipulations?
One reason is improved security. When Java doesn't allow pointers, the programmer is not allowed to freely step around in the computer memory. You also get rid of the C/C++ problem "undefined behavior". The rule of not having pointers in Java is also consistent with the way methods are supposed to be called in Java compared to C/C++ (call by reference).
See if you have pointers with you you are free to access physical memory locations that may be used by another process.Which will let you change content at that location corrupting the data used by another process. Pointer therefore pose issues of security and data corruption.
Hacking other process's memory is not at all a good idea.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
This can be done via standard mechanisms (e.g. JNI for java). What happens if something goes wrong in the c lib? Say a segmentation fault. Will that crash the containing process?
By contrast, calling a go lib from a go program seems much safer (or java lib from a java program). The lib can throw an exception, but the container can move on. Of course, things like OutOfMemory can throw off the whole process, but at least it's clear what happened.
Say a segmentation fault. Will that crash the containing process?
There's not much difference in that respect between C called from C, and C called from Java. A SIGSEGV will crash the process if unhandled; otherwise it will do whatever the handler does. But in general, it's not wise to recover from random program behavior by ignoring critical failures; your address space is likely in some strange state you didn't write code to deal with.
The real issue with calling C through JNI is that C can corrupt Java structures (say, the JVM heap) in ways that by design are not possible in Java. And the corruption doesn't show up until some time later, leading to frustration in debugging.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
Is there any way to create a java program that can executes itself while in a removable disk and cannot let any windows utilities or some third party software format that drive.
Short answer: no.
Long answer: the idea doesn't make sense in the first place. You see, any Java program would sit atop of any operating system. So, if your operating system decides to do something; how could something that runs atop of your OS (and that doesn't control your OS) prevent your OS from doing that?
If somebody has physical control over that drive; then there is nothing that you can do to prevent that person from erasing, formatting, ... that drive.
There might certain "workarounds"; such as hiding partitions; but the bitter truth is: unless you are able to some "hardware-based" write protection (that can't be disabled without destroying the drive), there is nothing you can do (see here for a similar question .. receiving similar answers).
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I want to improve a JAVA program performances using GPU programming.
After some research on the internet I found that it is possible if i use jcuda or jocl, but the problem is that the kernel code must be written in C in both cases.
and the algorithm that i want every thread to execute is very complicated to be written in C (it does some computations to know if there will be an accident between two aircrafts) so an object-oriented language is necessery.
Is there a solution ? or must we translate the whole project to C++ ?
Thanks for your help !
Simple rule: if it needs object orientation, it looses its performance. Even if you are using GPU acceleration.
I would advise you to identify the parallel parts of your program code. You do not have to transfer all of your algorithm to the GPU device. Is there any aspect of paralellization, e.g. arrays or grids that are filled?
What kind is your simulation message exchange? Is it explicit, i.e. sending messages around your kernels, or implicit via synchronization.
You should at least give us some more information about you algorithm and its data layout.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I know that C++11 memory model was inspired from Java memory model, but there has to be something that differentiates both these memory models.
Java uses synchronize and mutexes
C++11 uses atomics and mutexes
C# uses volatile
But what are the fundamental differences between these three in terms of multithreading in memory and in terms of read/write accesses for threads? Which memory model is better out of those three models? Can anyone please shed a light on this topic(only the differences) in detailed manner or provide a link that i can refer to? And how efficiently can these implemented on various real time systems?
Thanks in advance!
While this does not quantify the differences between the C++11 memory models, it does go into great detail about the C++11 model, which is the most recently codified, and therefore likely the most modern:
http://herbsutter.com/2013/02/11/atomic-weapons-the-c-memory-model-and-modern-hardware/
Once you understand C++11's model as a starting point, that will give you better tools for asking about other languages.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
Are there any ways in C and C++ to control the memory ram and registers according to our need? Eg. movement of data in ram from one location to other, changing values in registers, etc?
Is it possible in Java???
For memory management you should consider using a Memory Pool. Link.
Though you shouldn't be reinventing the wheel. Use a library instead that provides a clean templated interface to memory pools. Avoid malloc and memcpy as much as possible.
If you wan't to play with the registers you can include assembly code. Link.
I am not sure to understand your question, which is operating system, processor, and compiler specific.
With recent GCC you could do some of it (for instance, reserve registers to avoid them being used). And you could also customize the compiler (e.g. with MELT) to suite more needs. But such a customization means at least weeks of efforts.
You could also make a new backend in GCC (but this means months of work)
And recent standard C++11 library has notably std::allocator and a lot of memory management related stuff.