Hewlett Packard Interview Question
ConsultantsCountry: India
Interview Type: In-Person
In kernel context, we should loop (although not recommended) through task_struct list and check whose pid matches and then check the flags of it. If its CLONE_VM | CLONE_FS | CLONE_FILE | CLONE_SIGHNDL - it means these resources are shared, so that is a thread. Else, if its only SIGCHLD, its a process.
Do ps -AL | grep pid
- Punit Jain May 12, 20121st column is parent id and the second column is thread (LWP) id. if both are same then its a process id otherwise thread.