1. Do you know about Xiecheng ?

Coroutines are lighter threads . It is used to solve the problem of high cost of switching between threads and processes . Each state of the coroutine ( block , function ) The switch between the two is controlled by the program , Not kernel control , There is no need to switch between kernel mode and user mode , Reduced cost .

2.C and C++ static The difference between :
C++ There are static members and static member functions , Everything else should be the same .

3.C and C++ in struct The difference between :
If not typedef,struct Student{};…C++ Can be used directly in Student zhangsan; and C Must be in struct
Student zhangsan.
C++ in struct It can be used as a class , however struct All members in default is public Attribute

4. The difference between virtual function and pure virtual function :
Pure virtual functions are not implemented in the base class , Virtual functions are implemented in base classes .
Classes with pure virtual functions cannot instantiate objects , You must implement a pure virtual function in a subclass before you can instantiate an object .

5. Processes and threads :

Process is the smallest unit of resource allocation , There is independent virtual memory , Threads are CPU Minimum unit of scheduling , Threads share the heap memory of a process , File handle , global variable , Code snippet and other resources . A process can have multiple threads , Threads have no independent resources , So you have to rely on the process to run .

Process switching costs a lot , Need to switch page table global directory , Kernel state stack , Hardware context ( register ), Refresh TLB, Executing operating system scheduling code ( There is also the problem of cache penetration into memory caused by cache failure ). The cost of thread switching is small ,

Technology