From: Bill Cunningham on
Does the kernel call the same functions of POSIX that a human can use
the API for? I would like someone to make me clear on this. Thanks.

Bill


From: Ben Pfaff on
"Bill Cunningham" <nospam(a)nspam.invalid> writes:

> Does the kernel call the same functions of POSIX that a human can use
> the API for?

No.

> I would like someone to make me clear on this. Thanks.

You're welcome.
--
"Mon peu de succès près des femmes est toujours venu de les trop aimer."
--Jean-Jacques Rousseau
From: Bill Cunningham on

"Ben Pfaff" <blp(a)cs.stanford.edu> wrote in message
news:871vex4s8d.fsf(a)blp.benpfaff.org...
> "Bill Cunningham" <nospam(a)nspam.invalid> writes:
>
>> Does the kernel call the same functions of POSIX that a human can use
>> the API for?
>
> No.
>
>> I would like someone to make me clear on this. Thanks.
>
> You're welcome.

What exactly does it use then? The kernel to create and bind sockets for
netowkring assign PIDs and fork off processes and so on?

Bill


From: Patricia Shanahan on
Bill Cunningham wrote:
> "Ben Pfaff" <blp(a)cs.stanford.edu> wrote in message
> news:871vex4s8d.fsf(a)blp.benpfaff.org...
>> "Bill Cunningham" <nospam(a)nspam.invalid> writes:
>>
>>> Does the kernel call the same functions of POSIX that a human can use
>>> the API for?
>> No.
>>
>>> I would like someone to make me clear on this. Thanks.
>> You're welcome.
>
> What exactly does it use then? The kernel to create and bind sockets for
> netowkring assign PIDs and fork off processes and so on?

Operating systems I've worked on have their own functions for the tasks
they need to do internally. Those functions meet the specific needs of
the kernel, rather than conforming to the POSIX standard. Typically,
they are written in layers. The lowest layer deals directly with the
hardware, often requiring at least some processor specific code.

For specific information, read an internals book for a kernel that
interests you.

Incidentally, kernel programmers are just as human as application
programmers.

Patricia
From: Pascal J. Bourguignon on
"Bill Cunningham" <nospam(a)nspam.invalid> writes:

> "Ben Pfaff" <blp(a)cs.stanford.edu> wrote in message
> news:871vex4s8d.fsf(a)blp.benpfaff.org...
>> "Bill Cunningham" <nospam(a)nspam.invalid> writes:
>>
>>> Does the kernel call the same functions of POSIX that a human can use
>>> the API for?
>>
>> No.
>>
>>> I would like someone to make me clear on this. Thanks.
>>
>> You're welcome.
>
> What exactly does it use then? The kernel to create and bind sockets for
> netowkring assign PIDs and fork off processes and so on?

Why don't you go and see for yourself? You'd learn a lot by reading the
kernel sources. (It may be something else than /usr/src/linux,

$ find /usr/src/linux/ -name \*.c -exec grep -n fork {} /dev/null \;
....
/usr/src/linux/arch/ia64/kernel/process.c:393: * do_fork do_fork
/usr/src/linux/arch/ia64/kernel/process.c:428: * For SMP idle threads, fork_by_hand() calls do_fork with
/usr/src/linux/arch/ia64/kernel/process.c:480: * the psr.up/psr.pp bits must be cleared on fork but inherited on execve()
/usr/src/linux/arch/ia64/kernel/process.c:690: return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, &regs.pt, 0, NULL, NULL);
/usr/src/linux/arch/ia64/kernel/smp.c:296: /* this happens for the common case of a single-threaded fork(): */
/usr/src/linux/arch/ia64/kernel/smpboot.c:491:do_fork_idle(struct work_struct *work)
/usr/src/linux/arch/ia64/kernel/smpboot.c:496: c_idle->idle = fork_idle(c_idle->cpu);
/usr/src/linux/arch/ia64/kernel/smpboot.c:505: .work = __WORK_INITIALIZER(c_idle.work, do_fork_idle),
/usr/src/linux/arch/ia64/kernel/smpboot.c:527: panic("failed fork for CPU %d", cpu);
....
/usr/src/linux/kernel/fork.c:1261: total_forks++;
/usr/src/linux/kernel/fork.c:1264: proc_fork_connector(p);
/usr/src/linux/kernel/fork.c:1265: cgroup_post_fork(p);
/usr/src/linux/kernel/fork.c:1266: perf_counter_fork(p);
....
/usr/src/linux/kernel/sched.c:2241: int load_idx = sd->forkexec_idx;
/usr/src/linux/kernel/sched.c:2558: * Perform scheduler related setup for a newly forked process p.
/usr/src/linux/kernel/sched.c:2559: * p is forked by current.
/usr/src/linux/kernel/sched.c:2561: * __sched_fork() is basic setup used by init_idle() too:
/usr/src/linux/kernel/sched.c:2563:static void __sched_fork(struct task_struct *p)
/usr/src/linux/kernel/sched.c:2626: * fork()/clone()-time setup:
/usr/src/linux/kernel/sched.c:2628:void sched_fork(struct task_struct *p, int clone_flags)
/usr/src/linux/kernel/sched.c:2632: __sched_fork(p);
/usr/src/linux/kernel/sched.c:2842: * schedule_tail - first thing a freshly forked thread must call.
/usr/src/linux/kernel/sched.c:5131: * It also gets called by the fork code, when changing the parent's
/usr/src/linux/kernel/sched.c:6875: __sched_fork(idle);
/usr/src/linux/kernel/sched.c:7377: set_table_entry(&table[6], "forkexec_idx", &sd->forkexec_idx,
/usr/src/linux/kernel/sched_fair.c:51: * After fork, child runs first. (default) If set to 0 then
/usr/src/linux/kernel/sched_fair.c:1711: * get a chance to run but frequent forkers are not allowed to
/usr/src/linux/mm/hugetlb.c:265: * With the exception of reset_vma_resv_huge_pages() which is called at fork(),
/usr/src/linux/mm/hugetlb.c:267: * to reset the VMA at fork() time as it is not in use yet and there is no
/usr/src/linux/mm/hugetlb.c:1884: * from the time of fork. This would look like data corruption
/usr/src/linux/mm/hugetlb.c:1921: * at the time of fork() could consume its reserves on COW instead
/usr/src/linux/mm/mempolicy.c:597: * a newly forked child not yet visible on the task list, because
/usr/src/linux/mm/mempolicy.c:601: * mpol_fix_fork_child_flag().
/usr/src/linux/mm/mempolicy.c:608:void mpol_fix_fork_child_flag(struct task_struct *p)
/usr/src/linux/mm/mempolicy.c:618: mpol_fix_fork_child_flag(current);
/usr/src/linux/mm/oom_kill.c:86: * Processes which fork a lot of child processes are likely
/usr/src/linux/mm/oom_kill.c:88: * have an own mm. This prevents forking servers to flood the
/usr/src/linux/mm/prio_tree.c:72: * useful for fork's dup_mmap as well as vma_prio_tree_insert below.
/usr/src/linux/mm/swapfile.c:1044: * advantage of mmlist ordering, which clusters forked mms
....

--
__Pascal Bourguignon__