Welcome to LoseThos

Trivial Solutions Corp.'s LoseThos operating system is for programming as 
entertainment.  Maybe, you're a professional programmer who does hobby projects? 
 Maybe, you're a teenager who programs in your spare time?  Maybe, you're an 
older person who is not a professional, but likes to program for fun?  LoseThos 
is here to offer joy to programmers.  Here's my motivation and the 
LoseThos Constitition.

LoseThos is designed with simplicity as a goal.  Simplicity makes it fast in 
some ways and keeps the line count down.  It never switches privilege levels, 
never changes address maps, tends to load whole contiguous files and other, 
similar things which boost speed.  It's only 119,182 lines of code including the 
kernel, the 64-bit compiler, the graphics library and the tools.  More 
importantly, it's designed to keep the user's line count down -- you can do a 
"hello world" application in one line of code and can put graphics on the screen 
with a three line program!

The main things to know about LoseThos are that tasks have MAlloc/Free heap 
memory, not applications.  And, tasks have compiler symbol tables that persist.  
The symbol tables are like environment variables in terms of scope, but can 
include functions.

I hated learning one language for command line scripts and another for 
programming.  With LoseThos, the command line feeds right into the C+ (more than 
C, less than C++) compiler, line by line, and it places code into memory it 
MAlloc()s.  The compiler is paused at the command line, waiting for input.  
Naturally, you #include a program to load it into memory and, usually, start it. 
 During the boot process, many files get compiled before you have access to the 
command line.  (Don't worry, booting takes only a couple seconds.)  All the 
header declarations for the operating system are compiled and are available for 
use in your programs without needing to #include them.  Everything is truely 
compiled to native x86_64 code and nothing is "interpreted."

Statements at the global scope (outside the scope of C+ functions) execute 
immediately.  There is no main() function.  Instead, you give meaningful names 
to what would be main() functions and you invoke them by calling them with a 
statement in the global scope, usually at the bottom of your file.

I started with C syntax, but didn't like the command line for a directory 
listing looking like this:

Dir("*.*",FALSE);

So, I added default args from C++ and it looked like this:

Dir();

I didn't like that, so I made parentheses optional on calls with no args and it, 
now, looks like this:

Dir;

The syntax change created an ambiguity when specifying function addresses.  To 
resolve it, I  made a '&' required in front of function names when specifying an 
address of a function, which is better anyway.

Once I was no longer using standard syntax, I decided to change everything I 
didn't like.  Here are the new operator precedence rules.  See 
Departures from C/C++.  It's Biblical!  See Luke,5:37.
.

There are no object files in LoseThos and, normally, you don't make executable 
files either, but you can.  That's known as "static" compilation.

Tasks have no priority scheme and are never removed from the queue.  Instead, 
they poll whatever they are waiting on and swap-out.  (Swapping tasks takes half 
a microsecond.)  See Scheduler.  This keeps it simple.  It's might be a problem 
only if you had lots of tasks busy, which rarely happens on a home computer.  
The order of the tasks in the queue determines front-to-back window order.  See 
LoseThos MultiTasking.

The LoseThos file system is simple.  There is an allocation bitmap and all files 
are stored contiguously.  You cannot grow files.  It's geared toward reading and 
writing whole files.  Since whole files are processed, checksums and compression 
are possible.  Filenames ending in 'Z' are automatically compressed or 
uncompressed when stored or fetched.  LoseThos does supports direct block random 
access into files, however -- FRBlks() and FWBlks().  There is no PATH, but 
parent directories are searched when a file is not found.  This feature is used 
for default account files.  Note: the FAT32 filesystem is supported, which makes 
exchanging files with a dual booted other operating system easy.  If you don't 
have a FAT32 partition, you can use the LTZ program to transfer files to your 
primary operating system's partition.

I like being able to turn-off interrupts with Cli() and on with Sti() when I 
change a structure used in a multitasking environment.  LoseThos runs all 
programs in kernel mode, ring 0, so no instructions are off-limits.  Turning-off 
and on preemption with Preempt() is a less drastic measure that is usually 
sufficient.

The graphic resolution is poor, 640x480 16 color.  I've decided that this is the 
one and only resolution, forever.  It uses minimal CPU power.  A 1600x1200x24 
bit screen takes 37 times more memory, implying 37 times the CPU power.  Also, a 
fixed size keeps it simple with everybody machine having the same appearance.  6
40x480x4 VGA is universal on PC's.  Look on the bright-side -- you won't spend 
your time twiddling pixels for your games and you'll have tons of CPU power 
available, especially with multicore systems.  See LoseThos Graphics.

LoseThos is for hobbiest programmers on single user (at a time) home computers, 
not mainframes or servers, but it is multitasking.  The focus task is 
all-important so symmetrical multiprocessing is almost pointless.  Why does it 
matter if you can run two apps at the same time twice as fast when you really 
want to run one faster?  You could say LoseThos does master/slave 
multiprocessing.  The anticipated use for multicore is primarily putting 
graphics on the screen.  (Hardware graphics acceleration is not used, so this is 
possible.)  See LoseThos MultiCore.

There is no distinction between "task", "process" or "thread".  All have a task 
record, TaskStruct(), pointed to by the FS segment register and are accessed 
with "Fs->".  "Gs->" points to a CPUStruct for the current CPU core.  Each task 
can have just one window, but a task can have children with windows.  (By the 
way, the segment registers are just used as extra registers -- there is nothing 
segmented about LoseThos.)

In LoseThos, "Adam" refers to a task that is the father of all tasks.  He's 
never supposed to die.  Since tasks inherit the symbols of parents, system-wide 
stuff is associated with Adam.  His heap is like kernel memory in other 
operating systems.  See LoseThos Memory.  Since Adam is immortal, it's safe to 
allocate objects which must not be tied to any mortal task from off Adam's heap. 
 He stays in a server mode, taking requests, so you can ask him to #include 
something, placing that code system-wide.  A funny story is that originally I 
called it the "root" task and even had a "/LT/Root" directory ;-)

For easy back-ups, place everything you author in your HOME directory and 
subdirectories.  Then, use CopyTree().  That should make upgrading easy, too.  
To make an account use MkDir() to create a directory under /LT/Accts.  It will 
be HOME if you boot to it.  Recompile with InstallBoot() and make it boot your 
acct.  Customizable start-up scripts go in your HOME directory.  The default 
start-up scripts are in /LT/Accts, the parent of all accounts.  Copy the 
start-up files you wish to customize into HOME and modify them.  See Acct Files.

Typically, your usage pattern through the day will be repeatedly left or right 
clicking on filenames in a cmd line Dir() listing.  You left-click files to edit 
them and right-click to #include them.  To begin a project, type Ed(""); and 
supply a filename.  You can also run programs with F5 when in the editor.  Press 
ESC to save and exit the file.  You'll need to do a new Dir() cmd, periodically, 
so make a macro on your personal menu.  Access your personal menu by pressing 
the WINDOWS key, cursoring until you are on top of it and pressing the SPACE BAR
.

CTRL-T toggles plain text mode, showing format commands, a little like viewing 
html code.  CTRL-L inserts a nongraphic widget.  CTRL-R inserts a graphic 
resource or edits the graphic under the cursor.

CTRL-D brings-up the file manager.  It's pretty crappy.  I find I don't need it 
very often, believe it or not.

CTRL-ALT-E creates a new terminal window.  CTRL-ALT-X kills a window.  You'll do 
these periodically.  ALT-F pops-up the "favorites" document.  The favorites can 
be used from anywhere.  You can put anything there.  I use it as a handy TODO 
file, along with common links.

Grep() is your best friend.  There's a wrapper function called F() in your UserS
tartUp.CPZ file.  Feel free to make wrapper functions for functions you use 
often and customize the args.  By the way, Grep() or R() can be used to replace 
strings across multiple files.  You can access Grep() using CTRL-ALT-F.

As you browse code, use the WordStat window to look-up functions, etc.  Press CT
RL-SHIFT-F1 (or whatever number) to follow a symbol to it's source.  You can 
browse deeper and deeper.  You go back with CTRL-Q.

Use the Help Index or Demo Index to find-out what exists.  Press F1 for help or 
use the links on your menu.(WINDOW's KEY)  Also, look in the /LT/Demo or /LT/App
s directories for inspiration.


Take Tour