Re:Scheduling

Tigran Aivazian (tigran@sco.COM)
Thu, 1 Apr 1999 13:25:39 +0100 (BST)


This message is in MIME format. The first part should be readable text,
while the remaining parts are likely unreadable without MIME-aware tools.
Send mail to mime@docserver.cac.washington.edu for more info.

---559023410-5758-922969539=:28768
Content-Type: TEXT/PLAIN; charset=US-ASCII

Dear Livia,

Under Linux (as in any other UNIX-like OS) processes are created by means
of fork(2) system call. All system calls are prefixed with sys_ so, the
implementation of fork() is in sys_fork() function which is in
arch/i386/kernel/process.c file. If you build tags by means of this small
dotags script attached (from Pete Wyckoff), then you can easily lookup
things with:

vi -t sys_fork

Alternatively, you can compile the kernel with -g added to CFLAGS and use
gdb's list command to quickly lookup stuff.

As for termination, the system call _exit(2) is implemented in sys_exit()
(ok, it should be sys__exit() but that would be silly, so it is an
exception) of kernel/exit.c. A process can also terminate by a signal.

By looking at the sys_call_table[] of arch/i386/kernel/entry.S you can
learn how the sys_fork() function "becomes" a system call. It is also
instructive to notice the use of int 0x80 instruction to switch from user
to kernel mode when a system call is executed. This is in
include/asm-i386/unistd.h file, look at the _syscall*() macros.

Regards,
------
Tigran A. Aivazian | http://www.sco.com
Escalations Research Group | tel: +44-(0)1923-813796
Santa Cruz Operation Ltd | http://www.aivazian.demon.co.uk

Livia Catarina Soares said thus:
>Dear Colleagues

> I am here again with more questions.
> At this time my subject is: creation and termination process.
> QUESTION: Where did these procedures start??
> I mean ...Which is the first function called in both procedures??
> I am trying to understand the sequence of functions used in both
> procedures.
> I know that the main functions are do_fork and do_exit, respectively.
> However I could not trace all the behaviour.
> I would like to determine the exact point where a process is started and
> ended. I mean...the instant where the kernel realize that a
> process is started and ended.

---559023410-5758-922969539=:28768
Content-Type: TEXT/PLAIN; charset=US-ASCII; name=dotags
Content-Transfer-Encoding: BASE64
Content-ID: <Pine.SCO.3.94.990401132538.28768B@tyne.london.sco.com>
Content-Description: dotags script - useful for building kernel ctags

IyEvYmluL3NoDQojDQojIE1ha2UgbXkgZmF2b3JpdGUgd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Pj0wOyBpLS0pIHsNCgkgICAgaWYgKHN1YnN0cihyZSwgaSwgMSkg
PT0gIikiKSB7DQoJCXJlID0gc3Vic3RyKHJlLCAxLCBpLTEpIHN1YnN0cihy
ZSwgaSsxKQ0KCQlicmVhaw0KCSAgICB9DQoJfQ0KCSMgZmluZCBmdW5jIG5h
bWUNCglzcGxpdChyZSwgYXJyLCAiWyBcdF0iKQ0KCWZvciAoaT0xOyBpPDEw
MDsgaSsrKSB7ICAjIHNvIGl0IHdpbGwgdGVybWluYXRlIHNvbWV0aW1lDQoJ
ICAgIGlmICgoaiA9IGluZGV4KGFycltpXSwgIigiKSkgPiAwKSB7DQoJCWlm
IChqID09IDEpICAgIyBzcGFjZSBhZnRlciBmdW5jIG5hbWUgYW5kIGJlZm9y
IHBhcmVuDQoJCSAgICBmbmMgPSBhcnJbaS0xXQ0KCQllbHNlDQoJCSAgICBm
bmMgPSBzdWJzdHIoYXJyW2ldLCAxLCBqLTEpDQoJCWJyZWFrDQoJICAgIH0N
Cgl9DQoJIyB0YWtlIG9mZiB0aGUgIioiIGluIGNhc2UgdGhlIGZ1bmMgcmV0
dXJucyBhIHBvaW50ZXIgdG8gc29tZXRoaW5nDQoJaWYgKGluZGV4KGZuYywg
IlwqIikgPiAwKQ0KCSAgICBmbmMgPSBzdWJzdHIoZm5jLCAyKQ0KCXByaW50
ZiAiJXNcdCVzXHQlc1xuIiwgZm5jLCAkMiwgJDM7DQoJbmV4dA0KICAgIH0N
CiAgICB7IHByaW50IH0NCicgfCBzb3J0ID4gdGFncw0KZXhpdCAwDQo=
---559023410-5758-922969539=:28768--

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/