Re: parallel computation




"Andrzejewski Lukasz" <spamtrap@xxxxxxxxxx> wrote in message
news:fc09f02f9625a5d4c325cf463fa618a2$1@xxxxxxxxxxxxxxxxxxx
Hi.
I have Pentium D processor and i want to lern how to program second core
from the lowest level. ( without system calls if it possible ). Does
anybody could tell me how to make simple program for example one core is
summing some numbers , second multiply them. ? :)


well, it depends on what you are doing.

in you are in an existing OS, say windows or linux, then making syscalls is
the only real option (say, via use of pthreads, CreateThread, ...).


if doing a custom OS, or in DOS, ... it may make sense to fammiliarize
oneself with the intel docs. multiprocessor initialization is described in
Vol 3 (older), or Vol 3A (newer), and in both cases is described in chapter
7 (then again, if you don't know this already, then maybe it would be a bit
soon for trying to take this route).


if you want to implement custom multithreading on a single processor/core,
then this is much easier.

the most common teqnique is this (assuming one is either in DOS or a custom
OS kernel):
we set up an ISR, say, linked to the system clock (this may do other useful
things as well, like updating the kernel timer, ...).

on an interupt entry/return we:
push all the registers and other state to the stack;
change to a different stack;
do basic ISR stuff;
pop the registers and other state;
iret into the new thread/process.

IMO, it makes sense to have the entry and exit stack states being completely
symetric, so then the interrupt entry and exit points look just the same (no
real funky handling, apart from swapping out the stack in the process). it
is basically the same for processes, albeit process switching also implies
swapping out the page tables (CR4).

it may also make sense to swap over to a custom kernel stack as well for
doing kernel stuff (rather than using the userspace stack), but this is by
no means a requirement.


an alternative approach is to use the TSS mechanism, but this is generally
advised against (for good number of reasons).


Lukas



..

.



Relevant Pages

  • [Full-disclosure] PHRACK 64: ATTACKING THE CORE
    ... - The Slab Allocator ... - Slab overflow exploiting: ... - Forcing a kernel path to sleep ... - Stack Frame Flow Recovery ...
    (Full-Disclosure)
  • Re: [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c - bisected
    ... stack usages for you is that they contain a 'cpumask_t' on the stack. ... We can enable MAXSMP and raise the CPU limits some time in the future. ... not accept a specially built kernel, but only a kernel that has been ... know how extensively these distributions test and certify for many known ...
    (Linux-Kernel)
  • Re: Interrupt context...
    ... > gone through most of the posts on interrupt in usenet. ... > kernel stack and ISR is executed. ... More may be saved depending on the architecture. ... Here the kernel have assembler code to save all general ...
    (comp.os.linux.development.system)
  • Re: The Linux Staging tree, what it is and is not.
    ... if you compromize them and write the wrong ones to the stack, ... Load two user space fieldbus stacks on the same network card (remembering ... right, but that's the same, no matter if it runs in kernel or user ... need an objdict API to userspace...? ...
    (Linux-Kernel)
  • Re: The Linux Staging tree, what it is and is not.
    ... Load two user space fieldbus stacks on the same network card (remembering ... need an objdict API to userspace...? ... It depends where you split the stack between kernel and user space. ...
    (Linux-Kernel)