How do I create a directory, and any missing parent directories?

On Python ≥ 3.5, use pathlib.Path.mkdir: from pathlib import Path Path(“/my/directory”).mkdir(parents=True, exist_ok=True) For older versions of Python, I see two answers with good qualities, each with a small flaw, so I will give my take on it: Try os.path.exists, and consider os.makedirs for the creation. import os if not os.path.exists(directory): os.makedirs(directory) As noted in comments … Read more

“zero copy networking” vs “kernel bypass”?

What is the difference between “zero-copy networking” and “kernel bypass”? Are they two phrases meaning the same thing, or different? Is kernel bypass a technique used within “zero copy networking” and this is the relationship? TL;DR – They are different concepts, but it is quite likely that zero copy is supported within kernel bypass API/framework. … Read more

What is the difference between the kernel space and the user space?

The really simplified answer is that the kernel runs in kernel space, and normal programs run in user space. User space is basically a form of sand-boxing — it restricts user programs so they can’t mess with memory (and other resources) owned by other programs or by the OS kernel. This limits (but usually doesn’t … Read more

How to load second stage boot loader from first stage?

On x86 you would do the following (simplified): Have the bootloader load the n-th sector of the disk/floppy (wherever you’re booting from) into memory and execute it (i.e. load segment/offset and do retf). A better alternative is to search the filesystem for a certain filename (e.g. KERNEL.BIN) — but you’d need to know the file … Read more

How can I return system information in Python?

Regarding cross-platform: your best bet is probably to write platform-specific code, and then import it conditionally. e.g. import sys if sys.platform == ‘win32’: import win32_sysinfo as sysinfo elif sys.platform == ‘darwin’: import mac_sysinfo as sysinfo elif ‘linux’ in sys.platform: import linux_sysinfo as sysinfo #etc print ‘Memory available:’, sysinfo.memory_available() For specific resources, as Anthony points out … Read more

What is the overhead of a context-switch?

As wikipedia knows in its Context switch article, “context switch is the process of storing and restoring the state (context) of a process so that execution can be resumed from the same point at a later time.“. I’ll assume context switch between two processes of the same OS, not the user/kernel mode transition (syscall) which … Read more