 Hello, thanks for attending my talk. My name is Xiao Nan, and I'm very grateful for 4th Asia to give me the opportunity to get with the beach here. In this topic, I will share a small tool, iOS CPU, for BST operating systems. Okay, I will introduce myself first. I'm working in data storage in C2, also known as DSI. Personally, I like researching technologies related to computer infrastructure, such as operating system kernel, concurrent programming, debugging, etc. Since I'm not a native English speaker, so please forgive me for all the English and grammar errors in both talks and slides. Okay, this is the agenda of today's talk. Firstly, I will introduce how I began my journey with BST operating systems. Then I will introduce how iOS CPU is implemented in Linux operating system. Then I will introduce how I implement iOS CPU for BST operating systems. Okay, let's enter the section where I choose to use BST operating system. Before talking about BST, I will talk about Linux first. No one will deny that Linux is dominating the world now. I can give you two examples. The first is the top 500 supercomputers in the world are our Linux operating system. You can see this picture. The second example is about my previous employer, Hewlett-Packard Enterprise. The HPE has its own Linux operating system, which is called HP Unix. But I think now it puts the main focus on Linux operating system. I think it's the same situation as Oracle and Solaris. Oracle acquires the sun and its own Solaris, but I think Oracle also put more effort on Linux now. So why did I begin to use BST operating systems? Actually, there is no special reason. I'm just tired of Linux as I revere. For my company's library, all the servers run Linux. So I want to try something else, some different things. The first BST flavor I began to get my 130A is FreeBSD. It begins in January 2016. I installed FreeBSD on a machine and played it. The back product of this process is I read a simple manual which notes my experience of using FreeBSD. Then I dive into OpenBSD last year. In fact, I first learned OpenBSD in 2014. Because of the news that OpenBSD community even lacks the money for paid electricity bill. And I remember like the news in the Internet forums. Such as what's the correct method for open source community to live or money. Also, at that time, I knew OpenBSD is famous for its security. So after the usage of FreeBSD and OpenBSD, I decided to do some contributions of 4BSD operating systems. In Linux, there is a neat command called AliceCPU, which you can use to display CPU information. But for BST operating system, unfortunately, it doesn't have the out-of-force command like this. And it needs to use such as DMID code or how to read the demessage log to get the CPU information. So I decided to implement myself. Okay, let's enter the second part of this topic. I will introduce AliceCPU for Linux. So let's see the AliceCPU display the information on Linux Spark. We can display what architecture of the CPU and how many CPUs in the server. And such as CPU speed and cache size and the features CPU support. There is an interesting concept, the physical CPU and the logic CPU. The physical CPU number is equal to your socket number. So in my Linux machine, it can only have one physical CPU. But for logic CPU, every socket can have many cores. And for the CPUs such as Intel, it can support hyper thread for every core. So the logic CPU number is actually the thread number times cause number times the socket number. So we can see in this machine, we have two logic CPUs. How does AliceCPU work on Linux? The south code is here. Actually, there is no rocket sense. It's just read the information from the pseudo file system, PROC and SIS. Okay, so this is where you can see the PROC CPU info has provided the detailed information. Of the CPUs in the server. And what AliceCPU do is just read these files and pass it and display it. But unfortunately, it's removed from BSD operating system. At least on free BSD and open BSD. This means if I want to implement, I need to use other methods. Okay, let's enter the kernel part of this topic. How I implement AliceCPU for BSD operating systems. The first tool I use is using SIS control library function. This can be used to get or set system information. The name of the parameter specifies what information you want to get or set. And the old P is used to the current information. And the new is used to the new information you want to set. This is an example of using SIS control. And it's used to get the CPU number or CPU count in kernel server. We can see the MIB specifies we want to get the CPU numbers. And this CPU number variable is used to stop current CPU number. Because we don't need to set the new CPU number. So the last two parameters are now 0. Okay, I have compiled it before. So you just need to execute the program. We can see the CPU number of machine is 2. But the problem of SIS control is it can only get limited information. And not all BSD fliers support the same operation. So this means it can get very general. Such as the architecture and the byte order and the CPU number. These three items are only supported in BSD. So to get more detailed information of CPU, I need other measures. In x86 architecture, it provides a CPU ID instruction. This instruction can guide exhausted CPU information. For people interested in CPU ID, you can visit this big page. The competitors such as GCC and Clang provide a CPU ID marker. And we can use it to get the information which we are interested in. The GCC source code is here. It means it executed the CPU ID instruction. The input parameter is level. And the output parameter output is A, B, C, and D. So the tightest work of this process is I need to read the Intel and AMD documents to pass the return value. Intel and AMD have some difference in the CPU ID instruction. So I need to pass it carefully. So this is the example of using CPU ID. The input parameter is zero. And the output will start in EX, EBS, ECS, and EDX. This is you to get the vendor information of the current CPU. So let's check it. The program can get the vendor information of the CPU as a junior Intel. For every software, it's a very important phase. So to testing, I installed OpenBSD and FreeBSD in virtual machine. The host is Linux. And I will compare the results with LS CPU output in host and virtual machine to check whether my code has bugs or not. The other thing is because I only have Intel CPU and some developers have a test on AMD CPU and other BSD distributions such as Dragonfly, BSD, 90-PSD, etc. So the current status of this project is the south code. South code is here. And some developers creating the pause for FreeBSD, OpenBSD, or middleBSD. So I think if someone interested in this project, can use it directly. But the limitation is mainly support S86 families. But for other architectures such as ARM, Spark, or whatever, the information can only be get from this control library function. Because it lacks the CPU ID instructions like Intel or AMD. OK, it's time to wrap up this presentation. Finally speaking, the developing LS CPU program is a revolving project. I have learned two points. The first is how to develop a BSD program. The second thing is I got a lot of CPU knowledge, especially for S86 architecture. The other thing is Free and OpenSouth software has changed the world. So I think everyone can contribute to it such as coding, testing, or donating, and so forth. That's all. Thank you.