diff --git a/.gitea/workflows/docs.yaml b/.gitea/workflows/docs.yaml index 7f7f667..f3f7b4c 100644 --- a/.gitea/workflows/docs.yaml +++ b/.gitea/workflows/docs.yaml @@ -15,7 +15,7 @@ jobs: - name: Install software run: | sudo apt-get update - sudo apt-get install -y doxygen make rsync + sudo apt-get install -y doxygen make rsync clang clang-tools - name: Set up python3 uses: actions/setup-python@v5 @@ -28,7 +28,7 @@ jobs: pip install mkdocs mkdocs-material pymdown-extensions - name: Build - run: make docs + run: ./aux/docs.sh - name: Deploy env: diff --git a/Makefile b/Makefile index db8c3f6..98368e1 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,6 @@ platform ?= amd64 include make/apps.mk include make/kernel.mk include make/dist.mk -include make/docs.mk include make/libmsl.mk include make/liballoc.mk include make/libterminal.mk diff --git a/aux/compiledb.sh b/aux/compiledb.sh new file mode 100755 index 0000000..1be86cc --- /dev/null +++ b/aux/compiledb.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +set -x + +make -B all_compiledb_kernel +make -B all_compiledb_liballoc +make -B all_compiledb_libmsl +make -B all_compiledb_libprocess +make -B all_compiledb_libterminal +make -B all_compiledb_libstring diff --git a/aux/docs.sh b/aux/docs.sh new file mode 100755 index 0000000..9d4420e --- /dev/null +++ b/aux/docs.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +set -x + +./aux/compiledb.sh + +make -B docs_liballoc +make -B docs_libmsl +make -B docs_libprocess +make -B docs_libstring +make -B docs_libterminal + +mkdocs build diff --git a/docs/assets/images/only-processes.png b/docs/assets/images/only-processes.png deleted file mode 100644 index 1dc1763..0000000 Binary files a/docs/assets/images/only-processes.png and /dev/null differ diff --git a/docs/assets/images/processes-threads.png b/docs/assets/images/processes-threads.png deleted file mode 100644 index b68bccb..0000000 Binary files a/docs/assets/images/processes-threads.png and /dev/null differ diff --git a/docs/building_kernel.md b/docs/building_kernel.md index 63c76d5..d02f6ec 100644 --- a/docs/building_kernel.md +++ b/docs/building_kernel.md @@ -14,31 +14,18 @@ This article describes, how to build the kernel, how the build system works and cd into root of MOP3 source tree. -Build the kernel: +Run: ``` -make -B all_kernel buildtype= +./aux/devel.sh ``` -Build essential system applications: +This script does everything for you - builds the kernel, userspace apps, necessary libraries and such. +The buildsystem is quite compilcated, so it probably requires it's own article. + +For debugging you can do: ``` -make -B all_apps +./aux/devel.sh debug ``` -Prepare the ramdisk: -``` -make -B all_dist -``` - -Build ISO image: -``` -./aux/limine_iso_amd64.sh -``` - -Now you have an ISO image, which can be run my QEMU or you can burn it onto a CD. - -For the convenience of the developer, there's a magic "do all" script located in `aux`: -``` -./aux/devel.sh # optionally "./aux/devel.sh debug" for debugging -``` - -It does all the previous steps, just packed into a single script. +This will build with `buildtype=debug` as opposed to `buildtype=release`. You now can view symbols inside +of gdb or objdump. diff --git a/docs/processes_overview.md b/docs/processes_overview.md index 6d9bd9a..b815f8b 100644 --- a/docs/processes_overview.md +++ b/docs/processes_overview.md @@ -2,24 +2,15 @@ ## What is a process? -A process is a structure defined to represent an internal state of a user application's environment. This includes -the necessary stacks, code, data and other resources. A process (usually) has it's own address, but in certain -circumstances may share it with another process. +A process represents a piece of executing code, has it's own stack and CPU state. Think of it as a "task". There are no +kernel processes, only userspace processes. -## Only processes vs. processes-threads model +A process must be a member of a broader process group or procgroup for short. -### Overview +## Procgroups -MOP3 doesn't have a process-thread separation. Ususally in operating systems you'd have a "process", which consists -of multiple worker threads. For eg. a single-threaded application is a process, which consists of one worker. In MOP3 -we do things a little differently. We only have processes, but some processes may work within the same pool of (generally speaking) -"resources", such as a shared address space, shared memory allocations, mutexes and so on. An application then consists of -not threads, but processes, which are loosely tied together via shared data. - -#### Processes-threads model diagram -![Processes-threads model](assets/images/processes-threads.png) -#### Only processes model diagram -![Only processes model](assets/images/only-processes.png) +A procgroup owns things like memory, kernel resources and such. Processes work within the scope of a procgroup. Once all +procgroup's members die, the procgroup is considered unreachable and thus cleaned up. ## Scheduling diff --git a/init/init.c b/init/init.c index daca9a8..5713c79 100644 --- a/init/init.c +++ b/init/init.c @@ -18,7 +18,10 @@ void app_proc (void) { mutex_lock (MUTEX); for (int i = 0; i < 3; i++) - test (letter); + terminal_print (&letter, 1); + + for (volatile int i = 0; i < 1000*1000; i++) + ; mutex_unlock (MUTEX); } @@ -38,10 +41,11 @@ void app_main (void) { for (;;) { mutex_lock (MUTEX); - for (int i = 0; i < 3; i++) { - terminal_print ("hello\n", 6); - } - /* test (letter); */ + for (int i = 0; i < 3; i++) + terminal_print (&letter, 1); + + for (volatile int i = 0; i < 1000*1000; i++) + ; mutex_unlock (MUTEX); } diff --git a/liballoc/.gitignore b/liballoc/.gitignore index 5761abc..2a3afcd 100644 --- a/liballoc/.gitignore +++ b/liballoc/.gitignore @@ -1 +1,3 @@ *.o +*.json +docs/ diff --git a/liballoc/Makefile b/liballoc/Makefile index 7b4b8a1..570631f 100644 --- a/liballoc/Makefile +++ b/liballoc/Makefile @@ -25,4 +25,9 @@ clean: format: clang-format -i $$(git ls-files '*.c' '*.h') +docs: + clang-doc --format=md --output docs -p . $$(git ls-files '*.h') + mkdir -p ../docs/libs/liballoc + cp ./docs/GlobalNamespace/*.md ../docs/libs/liballoc + .PHONY: all clean format diff --git a/libmsl/.gitignore b/libmsl/.gitignore new file mode 100644 index 0000000..5bd58db --- /dev/null +++ b/libmsl/.gitignore @@ -0,0 +1,2 @@ +*.json +docs/ diff --git a/libmsl/Makefile b/libmsl/Makefile index 87db1e7..88ba85b 100644 --- a/libmsl/Makefile +++ b/libmsl/Makefile @@ -25,4 +25,9 @@ clean: format: clang-format -i $$(git ls-files '*.c' '*.h') +docs: + clang-doc --format=md --output docs -p . $$(git ls-files '*.h') + mkdir -p ../docs/libs/libmsl + cp ./docs/GlobalNamespace/*.md ../docs/libs/libmsl + .PHONY: all clean format diff --git a/libprocess/.gitignore b/libprocess/.gitignore index 5761abc..2a3afcd 100644 --- a/libprocess/.gitignore +++ b/libprocess/.gitignore @@ -1 +1,3 @@ *.o +*.json +docs/ diff --git a/libprocess/Makefile b/libprocess/Makefile index 10c41da..e571226 100644 --- a/libprocess/Makefile +++ b/libprocess/Makefile @@ -25,4 +25,9 @@ clean: format: clang-format -i $$(git ls-files '*.c' '*.h') +docs: + clang-doc --format=md --output docs -p . $$(git ls-files '*.h') + mkdir -p ../docs/libs/libprocess + cp ./docs/GlobalNamespace/*.md ../docs/libs/libprocess + .PHONY: all clean format diff --git a/libstring/.gitignore b/libstring/.gitignore index 5761abc..2a3afcd 100644 --- a/libstring/.gitignore +++ b/libstring/.gitignore @@ -1 +1,3 @@ *.o +*.json +docs/ diff --git a/libstring/Makefile b/libstring/Makefile index 598af92..8f498ee 100644 --- a/libstring/Makefile +++ b/libstring/Makefile @@ -25,4 +25,9 @@ clean: format: clang-format -i $$(git ls-files '*.c' '*.h') +docs: + clang-doc --format=md --output docs -p . $$(git ls-files '*.h') + mkdir -o ../docs/libs/libstring + cp ./docs/GlobalNamespace/*.md ../docs/libs/libstring + .PHONY: all clean format diff --git a/libterminal/.gitignore b/libterminal/.gitignore index 5761abc..2a3afcd 100644 --- a/libterminal/.gitignore +++ b/libterminal/.gitignore @@ -1 +1,3 @@ *.o +*.json +docs/ diff --git a/libterminal/Makefile b/libterminal/Makefile index 14061ea..7429b87 100644 --- a/libterminal/Makefile +++ b/libterminal/Makefile @@ -25,4 +25,9 @@ clean: format: clang-format -i $$(git ls-files '*.c' '*.h') +docs: + clang-doc --format=md --output docs -p . $$(git ls-files '*.h') + mkdir -p ../docs/libs/libterminal + cp ./docs/GlobalNamespace/*.md ../docs/libs/libterminal + .PHONY: all clean format diff --git a/make/docs.mk b/make/docs.mk deleted file mode 100644 index 222acbc..0000000 --- a/make/docs.mk +++ /dev/null @@ -1,4 +0,0 @@ -docs: - mkdocs build - -.PHONY: docs diff --git a/make/liballoc.mk b/make/liballoc.mk index 813995b..2fac6d1 100644 --- a/make/liballoc.mk +++ b/make/liballoc.mk @@ -1,10 +1,16 @@ all_liballoc: make -C liballoc platform=$(platform) all +all_compiledb_liballoc: + bear --output liballoc/compile_commands.json -- make -C liballoc platform=$(platform) all + clean_liballoc: make -C liballoc platform=$(platform) clean format_liballoc: make -C liballoc platform=$(platform) format -.PHONY: all_liballoc clean_liballoc format_liballoc +docs_liballoc: + make -C liballoc platform=$(platform) docs + +.PHONY: all_liballoc clean_liballoc format_liballoc docs_liballoc diff --git a/make/libmsl.mk b/make/libmsl.mk index fdb4060..a718815 100644 --- a/make/libmsl.mk +++ b/make/libmsl.mk @@ -1,10 +1,16 @@ all_libmsl: make -C libmsl platform=$(platform) all +all_compiledb_libmsl: + bear --output libmsl/compile_commands.json -- make -C libmsl platform=$(platform) all + clean_libmsl: make -C libmsl platform=$(platform) clean format_libmsl: make -C libmsl platform=$(platform) format -.PHONY: all_libmsl clean_libmsl format_libmsl +docs_libmsl: + make -C libmsl platform=$(platform) docs + +.PHONY: all_libmsl clean_libmsl format_libmsl docs_libmsl diff --git a/make/libprocess.mk b/make/libprocess.mk index 0399fc6..d770a3d 100644 --- a/make/libprocess.mk +++ b/make/libprocess.mk @@ -1,10 +1,16 @@ all_libprocess: make -C libprocess platform=$(platform) all +all_compiledb_libprocess: + bear --output libprocess/compile_commands.json -- make -C libprocess platform=$(platform) all + clean_libprocess: make -C libprocess platform=$(platform) clean format_libprocess: make -C libprocess platform=$(platform) format -.PHONY: all_libprocess clean_libprocess format_libprocess +docs_libprocess: + make -C libprocess platform=$(platform) docs + +.PHONY: all_libprocess clean_libprocess format_libprocess docs_libprocess diff --git a/make/libstring.mk b/make/libstring.mk index 7323c95..07f1f0a 100644 --- a/make/libstring.mk +++ b/make/libstring.mk @@ -1,10 +1,16 @@ all_libstring: make -C libstring platform=$(platform) all +all_compiledb_libstring: + bear --output libstring/compile_commands.json -- make -C libstring platform=$(platform) all + clean_libstring: make -C libstring platform=$(platform) clean format_libstring: make -C libstring platform=$(platform) format -.PHONY: all_libstring clean_libstring format_libstring +docs_libstring: + make -C libstring platform=$(platform) docs + +.PHONY: all_libstring clean_libstring format_libstring docs_libstring diff --git a/make/libterminal.mk b/make/libterminal.mk index c07e87d..9470520 100644 --- a/make/libterminal.mk +++ b/make/libterminal.mk @@ -1,10 +1,16 @@ all_libterminal: make -C libterminal platform=$(platform) all +all_compiledb_libterminal: + bear --output libterminal/compile_commands.json -- make -C libterminal platform=$(platform) all + clean_libterminal: make -C libterminal platform=$(platform) clean format_libterminal: make -C libterminal platform=$(platform) format -.PHONY: all_libterminal clean_libterminal format_libterminal +docs_libterminal: + make -C libterminal platform=$(platform) docs + +.PHONY: all_libterminal clean_libterminal format_libterminal docs_libterminal