ALT Linux Community general discussions
 help / color / mirror / Atom feed
From: Макс <arteev@protei.ru>
To: <community@altlinux.ru>
Subject: RE: [Comm] Как работает fork()?
Date: Wed, 25 Aug 2004 14:20:09 +0400
Message-ID: <20040825102013.1ED592443AD7@lab111.protei> (raw)
In-Reply-To: <000701c48a83$8026c5b0$0802a8c0@ivan>

>> Привет!
>> Поясните как работает fork().
>> Если не ошибаюсь, в результате вызова, дублируются, в частности, файловые
>> дескрипторы.
>> Что будет если:
>> 1. Файл открыт для эксклюзивного доступа. Вторая копия сможет работать с
>> файлом?

>> 2. Где-то в расшареной памяти есть мьютекс - используется несколькими
>> процессами. Процесс захватил мьютекс и вызвал fork. Каково будет
>>состояние мьютекса во второй копии.

>> 3. В процессе 2 потока. Один поток ожидает получения данных: int
>> result=read(h, .. , .. ); Данные не готовы и драйвер устройства усыпляет
>> поток:
>> static DECLARE_WAIT_QUEUE_HEAD(wq);
>>...
>>   interruptible_sleep_on(&wq);
>> В это время второй поток делает вызов fork. Что будет содержать result во
>> второй копии?

Мне кажется, что:
1. да
2. Идентичное
3. Ничего, т.к. вторая копия будет тоже ждать данных из read();

  reply	other threads:[~2004-08-25 10:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-25  9:11 AD
2004-08-25 10:20 ` Макс [this message]
2004-08-26  8:17 ` php-coder
2004-08-26  9:48   ` Re[2]: " AD
2004-08-27  7:57 ` Anton V. Boyarshinov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040825102013.1ED592443AD7@lab111.protei \
    --to=arteev@protei.ru \
    --cc=community@altlinux.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

ALT Linux Community general discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/community/0 community/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 community community/ http://lore.altlinux.org/community \
		mandrake-russian@linuxteam.iplabs.ru community@lists.altlinux.org community@lists.altlinux.ru community@lists.altlinux.com
	public-inbox-index community

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.community


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git