How does malloc work in a multithreaded environment?

glibc 2.15 operates multiple allocation arenas. Each arena has its own lock. When a thread needs to allocate memory, malloc() picks an arena, locks it, and allocates memory from it. The mechanism for choosing an arena is somewhat elaborate and is aimed at reducing lock contention: /* arena_get() acquires an arena and locks the corresponding … Read more

Why does GCC call libc’s sqrt() without using its result?

It doesn’t need to call sqrt to compute the result; it’s already been calculated by the SQRTSD instruction. It calls sqrt to generate the required behaviour according to the standard when a negative number is passed to sqrt (for example, set errno and/or raise a floating-point exception). The PXOR, UCOMISD, and JBE instructions test whether … Read more

how to run amd64 docker images on arm64 host platform

Using –platform is correct. On my M1 Mac I’m able to run both arm64 and amd64 versions of the Ubuntu image from Docker Hub. The machine hardware name provided by uname proves it. # docker run –rm -ti –platform linux/arm/v7 ubuntu:latest uname -m armv7l # docker run –rm -ti –platform linux/amd64 ubuntu:latest uname -m x86_64 … Read more

Intel 64, rsi and rdi registers

These registers were originally implicitly used in repetitive instructions, for instance MOVSB, which copy a byte from DS:SI (DataSegment:SourceIndex) to ES:DI(ExtraSegment:DestinationIndex), at the time of the 16-bits computers with segmented memory in real mode. And also as index registers in 16-bit addressing modes like [bx + si]. Right now, these registers are for example used … Read more

“Unexplainable” core dump

So, unlikely as it may seem, we appear to have hit an actual bona-fide CPU bug. https://web.archive.org/web/20130228081435/http://support.amd.com/us/Processor_TechDocs/41322_10h_Rev_Gd.pdf has erratum #721: 721 Processor May Incorrectly Update Stack Pointer Description Under a highly specific and detailed set of internal timing conditions, the processor may incorrectly update the stack pointer after a long series of push and/or near-call … Read more

How to check if Intel Virtualization is enabled without going to BIOS in Windows 10 [closed]

First method – Easiest option- Check your Task Manager If you have Windows 10 or Windows 8 operating system, the easiest way to check is by opening up Task Manager->Performance Tab. You should see Virtualization as shown in the below screenshot. If it is enabled, it means that your CPU supports Virtualization and is currently … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)