low-level

Scripting vs. Coding

梦想与她 提交于 2019-12-01 12:31:59
What is the difference between scripting and coding? I've done both, I can recognize both, but it seems in reality, the definitions are sketchy. First of all, am I right in assuming if you are "coding", your "code" must (be able to) compile into some system's machine or assembly, be it x86 assembly, windows assembly (like MASM), micro-controller assembly, etc. ? Am I also right to assume scripting doesn't ever compile, it's text is just run through a processing program like 'Microsoft Windows Based Script Host' (VB-Script parser)? I get some of the qualities of scripts and code, but on their

What happens when different CPU cores write to the same RAM address without synchronization?

只愿长相守 提交于 2019-12-01 10:59:48
Let's assume that 2 cores are trying to write different values to the same RAM address (1 byte), at the same moment of time (plus-minus eta), and without using any interlocked instructions or memory barriers. What happens in this case and what value will be written to the main RAM? The first one wins? The last one wins? Undetermined behavior? x86 (like every other mainstream SMP CPU architecture) has coherent data caches . It's impossible for two difference caches (e.g. L1D of 2 different cores) to hold conflicting data for the same cache line. The hardware imposes an order (by some

Scripting vs. Coding

喜欢而已 提交于 2019-12-01 10:53:58
问题 What is the difference between scripting and coding? I've done both, I can recognize both, but it seems in reality, the definitions are sketchy. First of all, am I right in assuming if you are "coding", your "code" must (be able to) compile into some system's machine or assembly, be it x86 assembly, windows assembly (like MASM), micro-controller assembly, etc. ? Am I also right to assume scripting doesn't ever compile, it's text is just run through a processing program like 'Microsoft Windows

How does a compiler compile a compiler?

こ雲淡風輕ζ 提交于 2019-12-01 02:04:50
问题 Coming from a high-level programming background, I am interested in learning about low-level programming. I want to know how a compiler is compiled? After looking at some articles in wiki, Numerical machine code is said to be lowest level language, but there has to be a compiler to compile this machine code. What language is that compiler written in? 回答1: Typically, compiler authors go one of two routes: Write the entire compiler in some other existing language. This is generally the simplest

Low level keyboard input from Windows

我们两清 提交于 2019-11-30 21:26:08
What win32 calls can be used to detect key press events globally (not just for 1 window, I'd like to get a message EVERY time a key is pressed), from a windows service? Brian R. Bondy You want to use Win32 Hooks. In particular a keyboard hook. You can read more about it here The type of hook you want is WH_KEYBOARD and you can set it via the Win32 API SetWindowsHookEx. Basically windows will call a function in a dll that you create everytime a key is pressed in any application system wide. The hook will call your function which will have this interface: LRESULT CALLBACK KeyboardProc( int code,

Can I change a user's keyboard input?

纵然是瞬间 提交于 2019-11-30 19:10:34
I found this keyboard hook code, which I'm trying to slightly modify for my purposes: http://blogs.msdn.com/toub/archive/2006/05/03/589423.aspx As an overview, I want to have the user press a key, say 'E', and have the keyboard return a different character, 'Z', to whatever app is in focus. The relevant method I changed now looks like: private static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam) { if (nCode >= 0 && wParam == (IntPtr)WM_KEYDOWN) { //The truely typed character: int vkCode = Marshal.ReadInt32(lParam); Console.WriteLine((Keys)vkCode); KBDLLHOOKSTRUCT replacementKey

Bit hacking and modulo operation

混江龙づ霸主 提交于 2019-11-30 17:39:43
While reading this: http://graphics.stanford.edu/~seander/bithacks.html#ReverseByteWith64BitsDiv I came to the phrase: The last step, which involves modulus division by 2^10 - 1, has the effect of merging together each set of 10 bits (from positions 0-9, 10-19, 20-29, ...) in the 64-bit value. (it is about reversing the bits in a number)... so I did some calculations: reverted = (input * 0x0202020202ULL & 0x010884422010ULL) % 1023; b = 74 : 01001010 b * 0x0202020202 : 1000000010000000100000001000000010 = 9494949494 :01001010010010100100101001001010010010100 & 10884422010

How are GUI's really made?

亡梦爱人 提交于 2019-11-30 17:26:52
问题 My question is Gui libraries like Qt and lets say for Windows operating systems how do they create all those graphical user interfaces(windows etc). Does each operating system gives API's or something else to do so?If yes, then how operating systems draw all those windows and things.Do they (operating systems) "control" the screen and then draw each pixel one by one to achieve their goal the GUI? I would like an answer that explains things at the lowest level possible but well i don't demand

How to simulate mouse click from Mac App to other Application

人走茶凉 提交于 2019-11-30 17:08:50
I am trying to simulate mouse click on iphone simulator from macos App for that I am using CGEvents . the process id is 33554 for iPhone simulator let point = CGPoint(x: 500 , y:300) let eventMouseDown = CGEvent(mouseEventSource: nil, mouseType: .leftMouseDown, mouseCursorPosition: point, mouseButton: .left) let eventMouseUp = CGEvent(mouseEventSource: nil, mouseType: .leftMouseUp, mouseCursorPosition: point, mouseButton: .left) eventMouseDown?.postToPid(33554) eventMouseUp?.postToPid(33554) I have also noticed that It simulates mouse click when ios simulator window is focused and only works

Handling SIGCHLD, how to record the return values of children as they die

为君一笑 提交于 2019-11-30 16:09:55
问题 void childSignalHandler(int signo) { int status; pid_t pid = wait(&status); struct PIDList* record = getRecordForPID(childlist, pid); if (record != NULL) record->returnValue = status; } Quick question: I want this handler to, when a child dies (this app spawns lots of children), get their return value and record it (last three lines). Will this do it, or am I getting all this API business wrong? Thank you for your time! (also, linux API terminology is creepy as hell, check for dying children