userland: move more multithreading from cpp-cheat!

Convert infinite_loop.c into loop.c. Keep all examples fast by default!
This commit is contained in:
Ciro Santilli 六四事件 法轮功
2019-09-07 00:00:03 +00:00
parent 986d6cfb7b
commit e0fb39c92a
8 changed files with 165 additions and 14 deletions

View File

@@ -12845,7 +12845,7 @@ Programs under link:userland/c/[] are examples of https://en.wikipedia.org/wiki/
*** File IO
**** link:userland/c/file_write_read.c[]
* Fun
** link:userland/c/infinite_loop.c[]
** link:userland/c/loop.c[]
==== malloc
@@ -12949,6 +12949,16 @@ It then walks over every page and writes a value in it to ensure that it is used
Algorithm used by the OOM: https://unix.stackexchange.com/questions/153585/how-does-the-oom-killer-decide-which-process-to-kill-first
==== C multithreading
Added in C11!
* link:userland/c/atomic.c[]: `atomic_int` and `thrd_create`
Bibliography:
* https://stackoverflow.com/questions/3908031/how-to-multithread-c-code/52453354#52453354
==== GCC C extensions
===== C empty struct
@@ -12986,8 +12996,6 @@ Programs under link:userland/cpp/[] are examples of https://en.wikipedia.org/wik
** link:userland/cpp/template.cpp[]: basic example
** link:userland/cpp/template_class_with_static_member.cpp[]: https://stackoverflow.com/questions/3229883/static-member-initialization-in-a-class-template
** link:userland/cpp/if_constexpr.cpp[]: C++17 `if constexpr`
*** https://stackoverflow.com/questions/12160765/if-else-at-compile-time-in-c/54647315#54647315
*** https://stackoverflow.com/questions/37617677/implementing-a-compile-time-static-if-logic-for-different-string-types-in-a-co
[[cpp-multithreading]]
==== C++ multithreading
@@ -12995,6 +13003,8 @@ Programs under link:userland/cpp/[] are examples of https://en.wikipedia.org/wik
* https://en.cppreference.com/w/cpp/header/thread[`<thread>`]
** link:userland/cpp/count.cpp[] Exemplifies: `std::this_thread::sleep_for`
** link:userland/cpp/thread_hardware_concurrency.cpp[] `std::thread::hardware_concurrency`
** link:userland/cpp/thread_get_id.cpp[] `std::thread::get_id`
** link:userland/cpp/thread_return_value.cpp[]: how to return a value from a thread
* https://en.cppreference.com/w/cpp/header/atomic[`<atomic>`]: <<cpp17>> 32 "Atomic operations library"
** link:userland/cpp/atomic.cpp[]
@@ -13093,6 +13103,7 @@ Bibliography: https://stackoverflow.com/questions/6988487/what-does-the-brk-syst
The following sections are related to multithreading in userland:
* language topics:
** <<c-multithreading>>
** <<cpp-multithreading>>
** <<pthreads>>
* ISA topics: