Single-Tasking?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
iskra
Posts: 14
Joined: Thu Oct 11, 2007 7:21 pm

Single-Tasking?

Post by iskra »

Hello there!

Firstly I want to thank all the people in here osdev.org forums for writing about os developing. As a newbie -and a hobbyist- to os developing I learned much about it from them.

I want to develop a OS (surprised?). But I'm a realist and I know my limits. So I've made a list that contains features my OS should have.

- Single-tasking. (Only one program runs at a time)
- No hard-disk. (This can be changed if I learn about file-systems)
- Basic graphical routines. (Like drawing lines, squares, circles)
- Basic file i/o routines
- Mouse support.
- Floppy file system. (Should I develop my own fs or stick with the FAT12?)
- ASM and C code.

* Nearly all topics in forum discuss about modern OS designs, implementations, concerns like multi-tasking, drivers, kernel model comparisons etc. Is there any good info page dedicated to single-tasked kernels? I searched a bit but couldn't find something.
* I found an OS called MikeOS -which i think rocks by the way-. It's fairly a simple design and code that anybody that knows a bit assembly can understand and it has everything that i could want to know about my tiny-mini-small OS. But I wonder about something. Everybody in forum that developed or developing an OS implements some systems such memory manager, gdt, idt etc. But in Mike's OS I couldn't see such sections and this leadeth me to think "there is no need to them in single-tasked os". Is this right?
* I don't want to make a clone of MikeOS. How can I improve my OS after it reaches the level of MikeOS? I think i should write a filesystem. What can you suggest about this?

I know there is a lot of topics that start with "omfg whre to begn" or "wheew what 2 do next?" and probably there may be ones want to flame me. So excuse me to start this topic for these questions, because I -really- searched about them and couldn't find satisfactory answers.

Warning: Forgive my English. My native language is not English and i can't use it properly yet.

Thanks for reading.
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Post by Dex »

Hi iskra, I will try to answer some of your ?, first i think MikeOS is a realmode OS (eg: 16bit) and you only need to set up GDT, IDT, etc, for Pmode OS (eg: 32 bit ).

Now you may think that realmode is OK, but remember you can only use 1 MB or so of ram, even if you have 512 MB of ram on your sys.
Now if realmode is what you want, you can take a look at MiniDos
http://board.flatassembler.net/topic.php?t=5275&start=0
I written it as a realmode OS tut, so it should help.

Now if you want to make a pmode single-tasking OS, you can take a look at my other OS, "DexOS" see here: http://www.dex4u.com/

Note: Do not think of single-tasking OS's as not being modern, as if you want a OS to do a single-task as fast as possible you would chose a single-tasking OS.
Eg: the xbox is single-tasking and do not have any memory management, and you would not call that a old design.
see here for Xbox spec
http://www.extremetech.com/article2/0,1 ... 116,00.asp

Here are some more pmode single tasking OS examples, like DexOS:
http://v2os.v2.nl/phpbb/index.php
http://v2os.v2.nl/old/
http://bos.asmhackers.net/

PS: I would stick to FAT to start with for file sys, but V2_OS has its own FS, so take a look at that .
User avatar
Colonel Kernel
Member
Member
Posts: 1437
Joined: Tue Oct 17, 2006 6:06 pm
Location: Vancouver, BC, Canada
Contact:

Post by Colonel Kernel »

Dex wrote:Note: Do not think of single-tasking OS's as not being modern, as if you want a OS to do a single-task as fast as possible you would chose a single-tasking OS.
Eg: the xbox is single-tasking
No it's not, according to the very page you quoted:
While the Xbox kernel is based on the NT/Windows 2000 kernel, it's extremely lean. There's no virtual memory paging, and only a single process is allowed (though that process can spawn multiple threads).
Top three reasons why my OS project died:
  1. Too much overtime at work
  2. Got married
  3. My brain got stuck in an infinite loop while trying to design the memory manager
Don't let this happen to you!
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Post by Dex »

Colonel Kernel wrote:
Dex wrote:Note: Do not think of single-tasking OS's as not being modern, as if you want a OS to do a single-task as fast as possible you would chose a single-tasking OS.
Eg: the xbox is single-tasking
No it's not, according to the very page you quoted:
While the Xbox kernel is based on the NT/Windows 2000 kernel, it's extremely lean. There's no virtual memory paging, and only a single process is allowed (though that process can spawn multiple threads).
There is a big difference between multi-tasking and multi-threading, if i have a OS that can only run one program at a time, it is single tasking, even though that program can have many threads.

DexOS is single tasking, even though it can run multi-threads in a program.
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

A task is a thread or a process. A thread is merely a lightweight process without it's own memory space.

Ergo, any multithreaded OS is multitasking.

/agree Colonel Kernel
iskra
Posts: 14
Joined: Thu Oct 11, 2007 7:21 pm

Post by iskra »

Thanks!

Dex, I looked in your works and I think they're pretty good for newbies.
but remember you can only use 1 MB or so of ram, even if you have 512 MB of ram on your sys.
"640k ought to be enough for everybody" :P

* If I get it right, in real-mode there is no memory protection. So, a user program can access memory sections that my kernel located in?

* Do you know a good tutorial about setting up a FAT system in your OS?

My questions aren't finished. I shall be back :P


OH! I almost forgot, in MikeOs there is a list of call names in mikedev.inc
os_print_string equ 0x8003 ; SI = zero-terminated string location
os_move_cursor equ 0x8007 ; DH, DL = row, column
os_clear_screen equ 0x800B ; (Nothing used)
...
How could he knows calls exact locations? Perhaps I should ask it directly to Mike?
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post by AJ »

In response to your last question, I haven't read his source (yet), bus I should imagine that a call table has been built and deliberately placed at, say, 0x8000 - this therefore gives a consistent interface.

As far as FAT is concerned, I learned about FAT12 from the source at http://bos.asmhackers.net/ (look at the boot sector in BOS 0.0.4). FAT is actually a really easy system to learn - have a look at http://www.win.tue.nl/~aeb/linux/fs/fat/fat-1.html. Once you know the layout of a) The FATs themselves and b) The root directory, eveything else comes from there. Just be happy that you have working general disk read/write code first.

Cheers,
Adam
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Post by Dex »

A program which splits up into several threads is said to be multi-threading. All the threads are working on the same TASK - doing whatever it is the program is designed to do. Well designed GUI programs (for systems such as Windows, MacOS and X-Windows) are multi-threading. If redrawing the screen takes a long time, they will process mouse and keyboard operations in mid-draw, resuming or restarting the drawing process when they have finished processing the input.


Computers nowadays can usually work on several tasks at the same time. The term tasks refers to unrelated jobs (unlike threads, which are all part of the same large job). On a multi-tasking computer, I can run a word processor in one window, a game in the second, an Internet browser in the third, an internet download in the fourth - and they all seem to work at the same time. Unlike multi-threading, the different tasks were written by different people at different times. The tasks don't "know" about each other - the word processor doesn't care that I'm running the game, not which one it is.
User avatar
Colonel Kernel
Member
Member
Posts: 1437
Joined: Tue Oct 17, 2006 6:06 pm
Location: Vancouver, BC, Canada
Contact:

Post by Colonel Kernel »

Dex wrote:A program which splits up into several threads is said to be multi-threading. All the threads are working n the same TASK - doing whatever it is the program is designed to do.
This is just a terminological argument. It has no relevance to the real concerns of OS devers, and I'm guessing, the original poster (iskra: when you said "single-tasking", did you mean "multi-threaded without processes", or "old-school like DOS" single-tasking?).

The difference between implementing a system with no multithreading or multitasking whatsoever and a system with just multithreading is much bigger than the difference between something that only has multithreading, like the Xbox kernel, and something that has processes too, like Windows or Linux. To implement multi-threading you have to implement context switching and worry about concurrency issues beyond just dealing with interrupts. Once you have that nailed, adding processes is not much more.
Top three reasons why my OS project died:
  1. Too much overtime at work
  2. Got married
  3. My brain got stuck in an infinite loop while trying to design the memory manager
Don't let this happen to you!
iskra
Posts: 14
Joined: Thu Oct 11, 2007 7:21 pm

Post by iskra »

I mean old-school single-tasking. Yes, like DOS.
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

Dex: c.f. linux kernel: before v2.6, each new (kernel) thread had it's own PID. Ergo, task! :) Only recently has the TID been made seperate from the PID.
M-Saunders
Member
Member
Posts: 155
Joined: Fri Oct 27, 2006 5:11 am
Location: Oberbayern
Contact:

Post by M-Saunders »

iskra wrote:OH! I almost forgot, in MikeOs there is a list of call names in mikedev.inc
os_print_string equ 0x8003 ; SI = zero-terminated string location
os_move_cursor equ 0x8007 ; DH, DL = row, column
os_clear_screen equ 0x800B ; (Nothing used)
...
How could he knows calls exact locations? Perhaps I should ask it directly to Mike?
Hi, glad you like MikeOS. I determine those exact locations by disassembling the kernel (MIKEKERN.BIN) and looking at the list of calls and rets after the 32K blank space.

You can see that a pattern emerges in the list in mikedev.inc, and when you add a new system call, it's pretty easy to guess as to which number it'll use :-)

Mike
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Post by Dex »

If we take all these examples, as multi-tasking, then there no such thing as single-tasking on the X86, because ever time the clock_tick firers, it saves the state of the program and runs a differant bit of code, than restore the program again.
iskra
Posts: 14
Joined: Thu Oct 11, 2007 7:21 pm

Post by iskra »

M-Saunders wrote: Hi, glad you like MikeOS. I determine those exact locations by disassembling the kernel (MIKEKERN.BIN) and looking at the list of calls and rets after the 32K blank space.

You can see that a pattern emerges in the list in mikedev.inc, and when you add a new system call, it's pretty easy to guess as to which number it'll use :-)

Mike
Hey, what disassembler you're using? I need one. :)
User avatar
Colonel Kernel
Member
Member
Posts: 1437
Joined: Tue Oct 17, 2006 6:06 pm
Location: Vancouver, BC, Canada
Contact:

Post by Colonel Kernel »

Dex wrote:If we take all these examples, as multi-tasking, then there no such thing as single-tasking on the X86, because ever time the clock_tick firers, it saves the state of the program and runs a differant bit of code, than restore the program again.
If there's no stack switch, there's no multithreading/multitasking/whatever you feel like calling it this week. With interrupts, execution is strictly nested. It's re-entrant, but not really concurrent.

More importantly, with true multitasking you can run one thread/task/whatever on each processor if there is more than one. DOS and its ilk can't do that.
Top three reasons why my OS project died:
  1. Too much overtime at work
  2. Got married
  3. My brain got stuck in an infinite loop while trying to design the memory manager
Don't let this happen to you!
Post Reply