简体   繁体   中英

Win32 Multithreaded Programming

A totally noob question. Inside Windows. Is it possible to make a thread without directly or indirectly calling a Win32 API function? For example using assembly language to call opcodes that make the CPU do atomic operations. I'm not certain but I'm guessing that the purpose of the OS is to provide this sort of thing. Though I'm not sure.

Are these sort's of threading things like CreateThread() and fork() provided by the OS fundamental for everything to be built on top or was it provided as a convenience?

When It comes to making processes and threads can you roll your own or must you use what the OS provides?

Atomics are a feature provided by the CPU. In general, if there's a CPU operation that you can perform, you can perform it, excepting those instructions reserved for a lower "ring" level.

Threads are a feature provided by the operating system.

As such you can't create threads 1 using assembly code, your user-space code does not have the requisite permissions. You must make the proper operating system kernel calls to request a new thread.

Threads don't really exist except as a function of what the operating system kernel does. One of the primary functions of a kernel is to manage threads and to schedule them on to the available compute resources.


1 This ignores things like virtualization or hypervisor features where your code can , but at a different level than the parent OS.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM