New tutorial released

This forums is for OS project announcements including project openings, new releases, update notices, test requests, and job openings (both paying and volunteer).
Post Reply
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

New tutorial released

Post by JamesM »

After much kicking from certain people who shall remain nameless, this morning I finally got around to writing the multitasking tutorial. It's part of the series at http://www.jamesmolloy.co.uk. Proofreaders would be most appreciated - I think some people here are waiting to see it anyway so I would appreciate it if people could point out mistakes here!

Cheers!

JamesM

http://www.jamesmolloy.co.uk/tutorial_h ... sking.html
User avatar
t0xic
Member
Member
Posts: 216
Joined: Sat May 05, 2007 3:16 pm
Location: VA
Contact:

Post by t0xic »

Haven't read it yet, and already have my own multitasking system, but
/me loves JamesM :D

Edit: only mistake I saw was that in the bottom part of the tutorial, some html formatting got messed up and caused text to turn red.

Other than that, great tutorial
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

Cheers t0xic:

That formatting problem was an issue with the lexer when a string constant breaks multiple lines.

Fixx0red now! :)
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post by AJ »

Hi,

As always, it looks brilliant and very complete (all other multitasking tutorials I've seen are basically along the lines of "push all regs, switch esp, pop all regs"). I won't be following it as when I already have the design in mind for Caracal and have already implemented multitasking in several test kernels, but I wish this tutorial had been around when I was starting out!

Quick scan proof read reveals no errors other than a minor formatting error at the end (last screenshot seems to overshoot your text frame by a half). I'll have a more detailed look sometime.

Cheers,
Adam
User avatar
piranha
Member
Member
Posts: 1391
Joined: Thu Dec 21, 2006 7:42 pm
Location: Unknown. Momentum is pretty certain, however.
Contact:

Post by piranha »

Awesome!
However....
1) The link that points to the source code (download here) points to nothing...you get a 404 error.

2) The code still triple faults in Qemu after a bunch of tasks are started....

-JL
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
xyzzy
Member
Member
Posts: 391
Joined: Wed Jul 25, 2007 8:45 am
Libera.chat IRC: aejsmith
Location: London, UK
Contact:

Post by xyzzy »

Looks cool, but the code to copy a physical frame looks... unsafe. It depends on the kernel being mapped in the same place in both the physical and virtual address spaces. Although not a problem for your tutorial, it will be problematic if someone wants to use that code in, say, a kernel running in the higher half.
jgraef
Member
Member
Posts: 47
Joined: Wed Jan 16, 2008 7:37 am
Location: Wonsheim, Germany

Post by jgraef »

Hi,

I think disabling paging to access physical memory is very slow.
User avatar
01000101
Member
Member
Posts: 1599
Joined: Fri Jun 22, 2007 12:47 pm
Contact:

Post by 01000101 »

yay! another tutorial.

when I get back to my house I will check it out deffinately.

Pe@cE
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

Hi guys, thanks for taking the time to go through it!
piranha wrote:Awesome!
2) The code still triple faults in Qemu after a bunch of tasks are started....
-JL
Yep, this will always happen as long as synchronisation primitives aren't implemented. It would be overkill to stick them in that tutorial (have you seen the length of it already?!) so just don't stress test it yet.
AlexExtreme wrote:Looks cool, but the code to copy a physical frame looks... unsafe. It depends on the kernel being mapped in the same place in both the physical and virtual address spaces. Although not a problem for your tutorial, it will be problematic if someone wants to use that code in, say, a kernel running in the higher half.
Alex, it's perfectly safe. As you say, it's tailored towards an identity mapped kernel (which is what we have in the tutorials). For a higher-half kernel, you *could* use the same technique, just with relative jumps.
jgraef wrote:I think disabling paging to access physical memory is very slow.
Hi. You're quite right. It is very slow. It involves a complete TLB refresh and also disables interrupts at one point, and don't even get me started on multiprocessing! but it's simple, and that's the aim of these tutorials. It's not to construct a foolproof, fantastic OS, it's to create one that does the job and is simple enough to be understood *fully*. Corner cases like this really do need consideration, but can be glossed over for the greater good in tutorials like this, IMHO.

As I say, the idea is to give an idea of how all the pieces fit together, not to do your work for you! :-)

I'll fix the 404 now. Thanks for the comments and please keep 'em coming!

James
User avatar
lukem95
Member
Member
Posts: 536
Joined: Fri Aug 03, 2007 6:03 am
Location: Cambridge, UK

Post by lukem95 »

very nice, i read through the code a while back, and the documentation looks amazing.

one thing i would include is how to start and kill a task though, or atleast a howto described in text. Like the start_task() example in the thread from a month or so back.
~ Lukem95 [ Cake ]
Release: 0.08b
Image
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

Good point. I'll add that now. Normally (unix wise) execve is required to start tasks (fork()/execve() pair) but I'll add a threaded version in there too.
bucket_brigade
Posts: 6
Joined: Sun Feb 10, 2008 3:11 am

Post by bucket_brigade »

Theres one thing i dont undestand about it. You don't seem to save the general purpose registers anywhere... Is that not necessery? Or are they saved implicitly somewhere?
blound
Member
Member
Posts: 70
Joined: Sat Dec 01, 2007 1:36 pm

Post by blound »

bucket_brigade wrote:Theres one thing i dont undestand about it. You don't seem to save the general purpose registers anywhere... Is that not necessery? Or are they saved implicitly somewhere?
Quote from article:
"
This relies on several things:

1. All the general purpose registers are already saved. This happens in the IRQ handler, so is automatic."
bucket_brigade
Posts: 6
Joined: Sun Feb 10, 2008 3:11 am

Post by bucket_brigade »

That's pretty much what i thought, funny how i missed that line. The whole readeip() stuff was pretty hard to wrap my head around, i think it needs a better explanation, maybe with some sort of graphic representation even :)
Post Reply