Current location - Health Preservation Learning Network - Slimming men and women - Who can introduce the kernel of MAC system in detail?
Who can introduce the kernel of MAC system in detail?
The kernel of Mac OS X system is a hybrid kernel called XNU. The core of XNU is Mach, and the BSD layer is built on Mach. They are all in the same address space and have the same high efficiency as a single core.

Mixed kernel:

Hybrid kernel hopes to combine the advantages of single core and microkernel. Core underlying services (including scheduling, process communication and virtual memory) are all contained in the core location, just like microkernel. For services outside this kernel, the kernel state is in the same memory space as this kernel.

XNU mach:

Mach and BSD have their own division of responsibilities, so let's say Mach has these core responsibilities.

Process and thread management: POSIX thread and NSThread that we usually use are in one-to-one correspondence with Mach layer threads. POSIX thread is a higher level abstraction of BSD layer of thread.

Virtual memory allocation and management.

Assign and schedule physical devices such as CPU.

Exception: Mach implements an exception handling mechanism based on the existing messaging mechanism. The following is a detailed introduction of application-level developers. How to catch Mach exceptions can be used to collect some crash information. Other crash collection articles can be found here.

If you want to catch mach exceptions, you need to register an exception port, which is valid for all threads of the current task. If you want to locate a single thread, you can use thread_set_exception_ports to register your own exception port.

When an exception occurs, first throw the exception to the exception port of the thread, and then try to throw the exception port of the task. When catching exceptions, you can do your own work, such as the current stack collection.

Extended data:

Analysis of HFS+ file system;

In addition to the goal of allowing users to store files stably, the file system is also the basis of various operating system functions. Every major version of MacOSX has added hundreds of new functions, many of which are heavily dependent on file system implementation. MacOSX 10.3 provides FileVault to encrypt user files, so the user's home directory is stored in the encrypted image of HFS+ file system.

References:

Baidu encyclopedia -Mac OS