low-level

Why do Java and C# have bitshifts operators?

南笙酒味 提交于 2021-02-16 16:59:49
问题 Is the difference between integer multiply(temporarily forgetting about division) still in favor of shifting and if so how big is the difference? It simply seems such a low level optimization, even if you wanted it the shouldn't the (C#/Java) to bytecode compiler or the jit catch it in most cases? Note: I tested the compiled output for C#(with gmcs Mono C# compiler version 2.6.7.0) and the multiply examples didn't use shift for multiplying even when multiplying by a multiple of 2. C# http:/

Why memory reordering is not a problem on single core/processor machines?

末鹿安然 提交于 2021-02-16 13:52:07
问题 Consider the following example taken from Wikipedia, slightly adapted, where the steps of the program correspond to individual processor instructions: x = 0; f = 0; Thread #1: while (f == 0); print x; Thread #2: x = 42; f = 1; I'm aware that the print statement might print different values (42 or 0) when the threads are running on two different physical cores/processors due to the out-of-order execution. However I don't understand why this is not a problem on a single core machine, with those

Low-level keyboard hook issue : Keyboard state losed when application is not focused (Delphi)

谁说胖子不能爱 提交于 2021-02-08 07:54:51
问题 I've been asked to develop a new application that will work along side the existing one. Both application will wait for a barcode reader input. I don't want our operator to scan a barcode twice: once for the existing application (16bit - clipper, no sources) and once for the new application. To solves this issue I've decided to use a low-level keyboard hook (written in Delphi). It looks perfect since 2 applications will need the barcode reader input and that my application will not be focused

Low-level keyboard hook issue : Keyboard state losed when application is not focused (Delphi)

跟風遠走 提交于 2021-02-08 07:54:37
问题 I've been asked to develop a new application that will work along side the existing one. Both application will wait for a barcode reader input. I don't want our operator to scan a barcode twice: once for the existing application (16bit - clipper, no sources) and once for the new application. To solves this issue I've decided to use a low-level keyboard hook (written in Delphi). It looks perfect since 2 applications will need the barcode reader input and that my application will not be focused

Custom heap/memory allocation ranges

坚强是说给别人听的谎言 提交于 2021-02-05 12:21:04
问题 I am writing a 64-bit application in C (with GCC) and NASM under Linux. Is there a way to specify, where I want my heap and stack to be located. Specifically, I want all my malloc'ed data to be anywhere in range 0x00000000-0x7FFFFFFF. This can be done at either compile time, linking or runtime, via C code or otherwise. It doesn't matter. If this is not possible, please explain, why. P.S. For those interested, what the heck I am doing: The program I am working on is written in C. During

Evil ctypes hack in python

放肆的年华 提交于 2021-01-27 13:43:07
问题 I'd like to start by saying that this question is asked purely out of interest, and I by no means intend to use something so incredibly evil in any serious project. (yes, it's that kind of a question) I've been trying to piece together some information in the inner workings of CPython, and as far as I've been able to work out, it should be possible to manipulate the actual values for small ints, so that (for instance) 1 + 2 could evaluate to something other than 3. I'm hardly on expert on

Behind the scenes of public, private and protected

心不动则不痛 提交于 2021-01-25 20:50:33
问题 I try to dive deeper and understand the differences between Public | Private | Protected in a low level perspective, in C++. How are the differences between the three expressed in the memory? 回答1: private , public and protected does not cause members to be stored in specific regions of memory. The access is checked by the compiler. On the very lowest level, there is no difference. However, access specifiers do have an effect on what guarantees you get on the order in which class members are

Behind the scenes of public, private and protected

主宰稳场 提交于 2021-01-25 20:48:49
问题 I try to dive deeper and understand the differences between Public | Private | Protected in a low level perspective, in C++. How are the differences between the three expressed in the memory? 回答1: private , public and protected does not cause members to be stored in specific regions of memory. The access is checked by the compiler. On the very lowest level, there is no difference. However, access specifiers do have an effect on what guarantees you get on the order in which class members are

how does the processor read memory?

江枫思渺然 提交于 2020-02-15 18:06:24
问题 I'm trying to re-implement malloc and I need to understand the purpose of the alignment. As I understand it, if the memory is aligned, the code will be executed faster because the processor won't have to take an extra step to recover the bits of memory that are cut. I think I understand that a 64-bit processor reads 64-bit by 64-bit memory. Now, let's imagine that I have a structure with in order (without padding): a char, a short, a char, and an int. Why will the short be misaligned? We have

how does the processor read memory?

不羁的心 提交于 2020-02-15 18:05:40
问题 I'm trying to re-implement malloc and I need to understand the purpose of the alignment. As I understand it, if the memory is aligned, the code will be executed faster because the processor won't have to take an extra step to recover the bits of memory that are cut. I think I understand that a 64-bit processor reads 64-bit by 64-bit memory. Now, let's imagine that I have a structure with in order (without padding): a char, a short, a char, and an int. Why will the short be misaligned? We have