Go, golang, channel, sync, slice and other interview questions

Go garbage collection mechanism: 1.8 mixed write barrier; runtime.GC active garbage collection

Reference counting;
mark-sweep: three-color mark algorithm
node replication;
generational collection;

Go's goroutine scheduling mechanism: scheduler, GMP (src/runtime/runtime.h source code)

G represents a goroutine object. Every time go is called, a G object will be created;
M represents a thread. Every time a M is created, a bottom thread will be created; all G tasks will eventually be executed on M ;
P represents a processor, and each running M must be bound to a P, just like threads must be executed on each CPU core;
the number of P is GOMAXPROCS (maximum 256), which is fixed at startup, generally Do not modify; the number of M and the number of P are not necessarily the same (there will be
sleeping M) (M is up to 10000); each P saves the local G task queue, there is also a global G task queue; the global task queue and Each local G
task queue exchanges with each other according to a certain strategy (when it is full, half of the local queue is sent to the global queue)

Go language can adapt to the reasons of high concurrency;

Explain the slice and map data structure in detail;

Defer recover panic execution sequence;

Chan select panic;

Inheritance order after structure binding method;

protobuf

protobuf: binary format; message represents the entity structure and consists of multiple message field fields; field message fields: including data type, field name, field rule, field unique identifier, and default value;
nested array in message: use field rule repeated marking Data can be repeated, equivalent to array or list;
define .proto file, name proto file packageName.MessageName.proto;
compile .proto file as target language file;
serialize and deserialize;

Concurrent

sync:Mutex互斥锁;RWMutex RLock();Once once.Do();Cond,Pool,
channel

What happens after the slice subscript goes out of range?

Guess you like

Origin blog.csdn.net/MENCO_/article/details/109157681