In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "what is the project structure and startup process of OS". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the project structure and startup process of OS".
I. the overall situation
First of all, our HarmonyOS is written in C language (nonsense) and compiled with gcc. Instead of using the traditional make, the project is built with GN. What is GN?
Generate Ninja is an upper-level compilation framework specially developed by Google for Ninja, which can generate input files that can be recognized by Ninja. Compiled by C++, GN is nearly 20 times faster than python-based gyp.
What is Ninja?
Ninja is a speed-oriented build tool put forward by a programmer of Google. Generally, programs on Unix/Linux are built and compiled through make/makefile, while Ninja greatly improves the construction speed by organizing the compilation task in parallel.
Highlight the word "fast". All in all, with the blessing of these two advanced tools, the compilation speed of this Hongmeng is very fast. I'm sure we all know that.
II. Project structure
1.applications, naturally is the user's various application code, here is our main battlefield. Specifically, applications/sample/wifi-iot/app/, this app directory is our business code.
2. The basic code of Basefield OS. Mainly includes globalization (global), DFX (hiviewdfx), common foundation (iot_hardware), security (security), startup recovery (startup) and other modules.
3.build, build the directory. The directory where files are stored during compilation.
4.docs, documentation. Many novices tend to ignore their own documents.
5.domains, domain. Looks like a couple of demo.
6.drivers, drive. The OpenHarmony driver subsystem is built by C object-oriented programming model. Through platform decoupling, kernel decoupling and compatibility with different kernels, the driver subsystem provides a unified driver platform base, which aims to provide developers with a more accurate and efficient development environment and strive to achieve one-time development and multi-system deployment.
7.foundation, basic module. The content is very complex, including Ability, ACE, Graphics and many other modules.
8.kernel, kernel code.
9.out, output directory. The generated firmware file is right here.
10. Prebuiltsfront LiteOS pre-compiled file. Some LiteOS .o and .a files are here to speed up compilation.
11.test, test directory. What exactly is it? it's not clear yet.
12.third_party, third party code.
13.utils, tool module. Like file access, timer, task and so on.
14.vendor, the code provided by the manufacturer. Here is the entry code for program startup, which should be given some attention. We can study it sometime.
15.build.py, compile the script. Basic usage: python build.py wifiiot
III. Start the process
I will not repeat HelloWorld's tutorial. I recommend referring to teacher Lian's article. The key is to understand one place:
SYS_RUN (HelloWorld)
This SYS_RUN is the macro that comes with the system, which tells the project that the entry function of our business code is HelloWorld. The SYS_ run macro is defined in the ohos_ init.hheader file, located in\ utils\ native\ lite\ include\ ohos_init.h, as follows:
/ * * @ brief Identifies the entry for initializing and starting a system running phase by the * priority 2. * * This macro is used to identify the entry called at the priority 2 in the system startup * phase of the startup process. \ n * * @ param func Indicates the entry function for initializing and starting a system running phase. * The type is void (*) (void) * / # define SYS_RUN (func) LAYER_INITCALL_DEF (func, run, "run")
The initialization and startup entry of the system startup phase are defined, and the type must be void (*) (void), that is, there can be no parameters and no return value. LAYER_INITCALL_DEF is also a macro, which is set to facilitate flexible adjustment of startup phase and priority. Specific readers can study it on their own.
Back in our HelloWorld, let's talk about threads. General business code will perform various tasks through a main loop, and the best way is to start a thread so that the entry function does not block and cause a series of problems. You can start a thread as follows:
OsThreadAttr_t attr; attr.name = "HelloTask"; attr.attr_bits = 0U; attr.cb_mem = NULL; attr.cb_size = 0U; attr.stack_mem = NULL; attr.stack_size = 10240; attr.priority = osPriorityNormal; if (osThreadNew (HelloTaskFunc, NULL, & attr) = = NULL) {printf ("[HelloTaskDemo] Falied to create HelloTask!\ n");}
At this point, the HelloWorld has been successfully completed, and have a preliminary understanding of the project structure and startup process.
Thank you for your reading, the above is the content of "what is the project structure and start-up process of OS". After the study of this article, I believe you have a deeper understanding of what is the project structure and start-up process of OS. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.