Re: kernel hangs quickly - non-root user reproducible



On Thu, 17 Jul 2008 19:08:42 +0200 H.Janssen <henny@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
| Dear Phil,
|
| phil-news-nospam@xxxxxxxx wrote:
|
|> I'm still not clear on what you are referring to. I do know that the
|> kernel supports "copy on write" where a page can be "shared in usage" as
|> long as the
|> processes sharing it don't modify/write it. This different than "shared
|> in content" where changes made by one process are immediately visible to
|> the
|> other process(es). In the "shared in usage" case, when one process writes
|> (or tries to write) on the page, the kernel makes a copy so the other
|> process
|> continues to see the original. In the case of files mapped in by more
|> than one process, this can be done by allowing a process to write, but
|> making sure that the page tables are updated so that the "in RAM" copy is
|> now exclusive
|> to the process that modified it. Other processes get a fresh copy by
|> means
|> of paging in a new copy from the original file. Otherwise I guess the
|> means to do that involves blocking the writes at the page table level and
|> when a process tries to write, make a copy right then if a backing store
|> one is not available.
|>
|
| Thanks for your extensive answer. This is exactly the kernel componet I
| mean. You can safely fork a process, and the kernel takes care of
| having the data "virtually" separate in parent and child without needless
| allocating memory and copying of data. I'm not an expert in programming, do
| not know how this is handled in case of threads, but I'm afraid you have to
| supply your own memory manager. (or take it from a clever library??)

Sharing mapped content between different virtual memory processes that could
make private changes has to be handled by the kernel. Sharing content within
the same virtual memory process between threads is a user space management
issue. Actually the sharing is easy ... keeping threads from stomping on each
other is the hard part. For example, each has to have its own private stack
range within the same address space. And that mean reserving address _space_
(not actually used pages, yet) for each stack as big as might possibly be used
by any thread. What threads really need is syncronization so there are not
any cases of 2 threads stomping on data they try to share (try even the simple
case of 2 threads incrementing a shared counter). That's a big part of what
a clever library is needed for with threads. FYI, I've done non-thread based
programming with no library present at all, in Linux. It was not any harder
than much of the assembly programming I used to do ages ago on IBM mainframes.

--
|WARNING: Due to extreme spam, googlegroups.com is blocked. Due to ignorance |
| by the abuse department, bellsouth.net is blocked. If you post to |
| Usenet from these places, find another Usenet provider ASAP. |
| Phil Howard KA9WGN (email for humans: first name in lower case at ipal.net) |
.



Relevant Pages

  • Re: [PATCH] FRV: do_gettimeofday() should no longer use tickadj
    ... The kernel build process doesnt remove them and i havent ... IRQ prototypes and a difficult generic feature like irqtrace breaks? ... Sharing code has a price most of the time, ... artificial and most of it is not caused by the indirections. ...
    (Linux-Kernel)
  • Re: best way to communicate with forked processes
    ... all memory protection between your threads instead of limiting memory ... sharing to just the parts you need to share. ... then the entire process crash. ... mis-understandings of concurrent programming. ...
    (comp.unix.programmer)
  • Re: best way to communicate with forked processes
    ... all memory protection between your threads instead of limiting memory ... sharing to just the parts you need to share. ... One should use thread programming when it becomes messy to achieve ... use of shared state concurrent programming model. ...
    (comp.unix.programmer)
  • Re: threading support in python
    ... Being explicit about what you're sharing is generally better than not. ... Part of the win of programming in Python instead of C is having the ... language do memory management for you--no more null pointers ... Python doesn't actually support that as of yet, ...
    (comp.lang.python)
  • Re: VC6 serial port usage in a tabbed dialog application
    ... If you're not fully comfortable with core C/C++ programming then it's ... Many people helping here are doing it in their free time, ... I have spent several days doing reaearch regarding pointers or sharing ... I have no problems sharing the hComm handle with Web1a and Web2a. ...
    (microsoft.public.vc.mfc)