On Thu, 01 Apr 2021 20:20:04 +0530, Navin P said:

> After printing the task->start_boottime as 53rd field, i found
> multiple process containing same value due to a race. The race exists
> for p->start_time as well.

Well, yeah.  There's no existing reason that the kernel shouldn't be able to
spawn processes on two CPUs in parallel (and initialize the start_time field to
the same value along the way).  There should be as little synchronizing locking
as possible, and if you need to do something that requires locking, you should
probably piggyback it on top of a code section that already has the appropriate
locks in place.

> What are the other ways  that can be used to fix this problem ?

Is there a particular reason why your code *needs* to have different unique
values for the start_time and start_boottime fields?  If your code needs
something unique per-process, the tuple (start_time, PID) *will* be unique
system-wide.  Or just PID.

In other words, what problem are you trying to solve by making the start_time
unique?

Attachment: pgp_8DZIJfaU5.pgp
Description: PGP signature

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

Reply via email to