Multitasking???

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.
Post Reply
KieranFoot

Multitasking???

Post by KieranFoot »

In operating multitasking operating systems if one program crashes the system can keep on running, right?

How does this work...

As far as i know multitasking can be described in a series of steps:-
  • Save current system registers
  • Load tasks registers
  • Run x bytes of task code
  • Save tasks registers
  • Load saved system registers
  • Return to system for next task call
Is this right ???

If so i cannot see how a crash protection mechanism would work... ::)
crc

Re:Multitasking???

Post by crc »

In operating multitasking operating systems if one program crashes the system can keep on running, right?
That's not right. If everything runs in the same ring, any process can crash the entire system. Using ring0 for kernel and ring3 for apps should improve the overall stability IIRC.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Multitasking???

Post by Pype.Clicker »

Multitasking doesn't imply a program can run independently of other programs. Multiprogramming (e.g. using multitasking and multiple address space, giving each program a separate memory space and a separate 'processor state') more or less help, but not necessarily.

A program that crash may leave files locked, shared things in invalid states, etc. It does not automatically crash the whole system with it, but it can lead much of the system in an incoherent state.

Multitasking simply means that if a program is *blocked* because waiting for something, it usually doesn't block other programs along, and thus the system can go on with (other) useful job.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:Multitasking???

Post by Solar »

I think KieranFoot's non-understanding sits at a deeper level: memory protection...

Modern CPU's contain an auxiliary feature called a "Memory Management Unit". This part of the CPU provides a mapping from "virtual addresses" (used by the running process) to "physical addresses" (i.e., actually existing RAM addresses).

Since every running task gets its own, non-overlapping memory map, a crashing task cannot damage another task since it cannot "see" the other task at all.

That taken into account, your list would look like:

* save current system registers;
* point MMU to new tasks' memory map;
* load new task's registers;
* run x bytes of task code;
* repeat.

This is grossly oversimplified, but should give an idea of how tasks can be protected from each other. Any communication between tasks is done via the kernel (which is the only part of the system "seeing" all tasks).
Every good solution is obvious once you've found it.
distantvoices
Member
Member
Posts: 1600
Joined: Wed Oct 18, 2006 11:59 am
Location: Vienna/Austria
Contact:

Re:Multitasking???

Post by distantvoices »

@solar:
I beg your pardon, and acknowledge herewith that you have said "grossly oversimplyfied". Nevertheless:

it should be, if we wanna do multi*threading*, in a way like this:

if(tcb->memory_map!=cpu->memory_map)point_cpu_to_memorymap(tcp->memory_map)

This way, we avoid Transaction Lookaside buffer flushing if
only switching to another *thread* inside the actual *process* *gg* I'm not nitpicking am I? ];->
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:Multitasking???

Post by Solar »

It all depends on what you want to do, and the CPU you're running on... take note that on some CPUs the MMU holds more than one memory map in cache... ;)
Every good solution is obvious once you've found it.
Post Reply