Boomslang OS is an OS simulator built on python. It is a model OS which can be used for teaching OS course just like xv-6 but since it is written in python it's easier to understand the concepts without going deep into language specifics and apart from that creating an OS is fun and educative.
While building the project I ran into many bugs but one took the most amount of time and print statements were a bug in the shell program. I wanted to add a feature to run any script from the shell. It is easy to run system commands since we know from which path we have to import and the path is going to be a sub-package of the root OS package. But in the case of a user-defined script, we can't be sure that the file will be under the root package. So, importing the module seems out of the question. The solution I came up with was to execute the script by reading it and then executing it via
exec
and retrieving the needed main function vialocals
. It took a while to devise this solution.Technologies used
Discussion