Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 21 Oct 2002 17:03:16 +0200
From:      Pawel Jakub Dawidek <nick@garage.freebsd.pl>
To:        freebsd-hackers@freebsd.org
Subject:   SMP and race conditions.
Message-ID:  <20021021150316.GT80034@garage.freebsd.pl>

next in thread | raw e-mail | index | archive | help

--8+odlFQADydc3R4z
Content-Type: text/plain; charset=iso-8859-2
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Hello hackers...

We got for example a kld module and we have catched some syscall.
Now we want to change effective uid of process, but not curproc.
How to lock this process?

	struct proc *proc;
	uid_t olduid;
	[...]
	if ((proc =3D pfind(123)) =3D=3D NULL)
		return (ESRCH);
	olduid =3D pc->pc_ucred->cr_uid;
	change_euid(proc, 0);
	/* now some simple action */
	change_euid(proc, olduid);

How to be sure that process 'proc' arn't running  on other CPU?

Function lockmgr() is used for problems like this one?
Where I could find some more information about it?
For now I've wrote only comments in /sys/sys/lock.h, etc.
There are any papers about programming in SMP?

--=20
Pawel Jakub Dawidek
UNIX Systems Administrator
http://garage.freebsd.pl
Am I Evil? Yes, I Am.

--8+odlFQADydc3R4z
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (FreeBSD)

iQCVAwUBPbQXND/PhmMH/Mf1AQEbfgP/TByep1661N/MZAI8/c3cFNwra7Q/ymP8
v0nNZTgx2rOzmb0nQbR2PSjQt8sHOqaIScb0OZdi+6qyCnRxYkCeTNw7HDeU7IM3
YmSmLtSZ0Kc+ye5GICXCySwcFTk6PqHZNVGKEPIyWb1r94pwuvuQsOz7ongPS4Gv
mupFuR/IR9s=
=VnHw
-----END PGP SIGNATURE-----

--8+odlFQADydc3R4z--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20021021150316.GT80034>