Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Geek Culture / Single executable file multitasking capable OS

Author
Message
Dark Java Dude 64
Community Leader
15
Years of Service
User Offline
Joined: 21st Sep 2010
Location: Neither here nor there nor anywhere
Posted: 14th May 2012 06:28 Edited at: 14th May 2012 11:05
Hi everyone! Sometime yesterday I came up with an idea for an operating system that would be capable of multi tasking though having only one executable file.

Basically, the OS would simply edit its own exectutable according to information inside of a program file. In other words, any application you would install would simply be a patch like file giving the OS information on exactly how to change its own executable, while it was running.

The OS would multitask by treating each one of these applications like a separate subroutine. Therefore, installing a new application would simply add a new subroutine to the OS executable file. During runtime, when you start an application, the OS would append to the application's respective subroutine a small bit of code that would dispatch the subroutine belonging to the next process that needs to be run. This way, no dispatcher program would be needed to dispatch different programs.

What do you guys think of this concept? Does it already exist?

Also, I have a couple questions. What is the difference between a thread and a process in regular multitaking OS's? Then, what is hyperthreading, i know that is a trademarked name for something intel processors do. Thanks!
Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 14th May 2012 12:23
I'll try and answer some questions, but it's likely to be incorrect. A process is a collection of threads, for example a game would have a process, but within that there would be multiple threads for input, physics etc.

Hyperthreading is when a single core can run two threads simultaneously, effectively making it two cores.

The thing I don't like about your OS idea (I have no idea if it would work) is that every program you run would HAVE to be installed.

Also, if one application crashes, your entire OS crashes, you can't terminate a single application.

bitJericho
23
Years of Service
User Offline
Joined: 9th Oct 2002
Location: United States
Posted: 14th May 2012 14:35
Is this for your console? You should keep your posts together to give some sort of relavence to your discussions.

Your post is so complex I don't even know where to begin. I guess I'll throw a question out there, what benefit would a single executable file provide?

Dark Java Dude 64
Community Leader
15
Years of Service
User Offline
Joined: 21st Sep 2010
Location: Neither here nor there nor anywhere
Posted: 14th May 2012 15:48
@Indicium Ah! That all makes sense.

Quote: "Is this for your console? "
Nope.

What benefit would a single exec serve? Not sure, just curious.
Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 14th May 2012 16:22
I can only think of one benefit a system like this would have, but I still think the disadvantages outweigh it, due to being only a single executable, it'd be very portable! You could just stick it on a flash drive and run it on any computer.

Kevin Picone
23
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Diggsey
20
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 14th May 2012 21:22 Edited at: 14th May 2012 21:23
At the OS level all of these high level concepts like executables, processes, threads, etc. don't exist, they are all features that the OS itself provides. The OS isn't just another executable file, because executables when loaded each have their own block of virtual memory of a certain size. An OS exists in physical memory, so the "size" of the OS is effectively the whole memory, and since OSes load other executables into memory, yes it is a bit like modifying the OS each time you start a program.

The only real difference between what you're saying and reality is that OSes use the memory protection features in the hardware to make sure that each process gets its own virtual address space and so can only access its own part of the physical memory. I don't really see the advantages of not doing this.

[b]
Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 14th May 2012 22:33
Well, that just goes to show what I know.

Airslide
21
Years of Service
User Offline
Joined: 18th Oct 2004
Location: California
Posted: 16th May 2012 04:28 Edited at: 16th May 2012 04:29
It might be worth reading up on the x86 instruction set to get an idea about what is happening at the lowest level. Don't restrict yourself to normal assembler tutorials, really look at the processor's feature set, as you'll likely come across information that explains how an OS can make use of the instruction set to implement the fundamental features you expect from an operating system. The Intel manuals are pretty good for this.

Of course the specifics differ if you are talking about ARM or PowerPC architectures, but you'll get a general idea. You may also find your notion of how a computer works may change a bit as you realize just how abstract even the relatively low-level C programming language really is compared to the hardware (and if an OOP or Basic language is your thing, there's even more going on beneath the covers).
Dark Java Dude 64
Community Leader
15
Years of Service
User Offline
Joined: 21st Sep 2010
Location: Neither here nor there nor anywhere
Posted: 16th May 2012 07:32
Oh yeah, i already know all that stuff... I should look at x86 though.
Dark Java Dude 64
Community Leader
15
Years of Service
User Offline
Joined: 21st Sep 2010
Location: Neither here nor there nor anywhere
Posted: 17th May 2012 08:04 Edited at: 17th May 2012 08:14
Sorry to bump but i have got one more question i would like to add. I know context switches are usually performed by the processor when it recieves an interrupt from a timer. I was also reading up on dispatchers. as quoted from wikipedia, a dispatcher is a module that has to run every time a context switch occurs and i was just wondering if it is a process in itself or if it something else.

Thanks!!

edit

After a little more research it seems as if the process's time slice runs out, an interrupt is sent to the processor and it performs the switch however if the scheduler decides that a new process needs to be swapped in it will use the dispatcher to get the new one in. Is that right?
Diggsey
20
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 17th May 2012 18:26 Edited at: 17th May 2012 18:28
Each core in each processor runs exactly one task at all times. If some user-mode code is running and an interrupt occurs, the processor stops, switches to kernel-mode, pushes the instruction pointer onto the stack and then starts executing the handler for that interrupt.

The handler first saves all the registers (including the stack pointer), loads the kernel-mode stack, and then does whatever needs to be done (ie. if it's a notification that a key was pressed it might add the key to a queue of keypresses to be processed). Next, the scheduler runs (even if it's not a timer interrupt, the OS will practically always take the opportunity to switch tasks anyway because it's very little extra cost).

The scheduler finds the next thread to run (usually the one that hasn't run for the longest) and tells the dispatcher to switch to that thread. Switching to a thread involves restoring all the registers (including the stack pointer) for that thread and then performing an "IRET" (interrupt return) which is the only way to switch to user-mode.

Since the restored stack has the instruction pointer on top for where that thread was interrupted, it will automatically be popped off by the processor and execution will continue from that point.

There is a slight difficulty though: although the above mechanism makes it very easy to resume a thread that was previously interrupted, there's apparantly no way to create a new thread (since the only way to enter user-mode is with an IRET. The way to do this is to pretend that it was previously interrupted: manufacture a new stack with the desired instruction pointer on top, set the stack pointer to this new stack and perform an IRET.

So, in short, the dispatcher is just a very few bytes of code in the kernel which restore the registers of a given thread

[b]
Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 17th May 2012 22:57
Diggsey, how on earth do you know all that in such detail? xD

Dark Java Dude 64
Community Leader
15
Years of Service
User Offline
Joined: 21st Sep 2010
Location: Neither here nor there nor anywhere
Posted: 18th May 2012 00:29 Edited at: 18th May 2012 00:29
I think i knew most of that but you filed in all of the potholes!! Thanks!
Diggsey
20
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 18th May 2012 04:38
Quote: "Diggsey, how on earth do you know all that in such detail? xD"


I've written two halves of two OS kernels

[b]
Dark Java Dude 64
Community Leader
15
Years of Service
User Offline
Joined: 21st Sep 2010
Location: Neither here nor there nor anywhere
Posted: 18th May 2012 04:53
Of what OS?
Diggsey
20
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 18th May 2012 15:59
The first one was called Dragon OS, which I worked on with Aaron Miller for a while, the second was called Arcane OS which I worked on with Kaedroho. With Arcane OS we managed to get high resolution graphics to work.

[b]
Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 18th May 2012 16:08
Oh awesome, I didn't know you worked on Arcane too, Kaedroho let me try it out a while back.

Dark Java Dude 64
Community Leader
15
Years of Service
User Offline
Joined: 21st Sep 2010
Location: Neither here nor there nor anywhere
Posted: 19th May 2012 00:12
Thats pretty sweet man!!

Login to post a reply

Server time is: 2026-07-21 18:55:01
Your offset time is: 2026-07-21 18:55:01