Monday, November 5, 2012

Linux Process Management: Project topics

This page contains some project topics related with the process management.

1> Dynamically changing the max_pid number.

Currently maximum number of process could be created is fixed and specified in the file /proc/sys/kernel/pid_max (PID_MAX_DEFAULT).

How could we patch linux kernel so this number is changed automatically and dynamically. Suppose if max number of processes could be created is 32767. Now all pids are allocated to the process. Now if any user wants to create new process, a max_pid number will be increased and user will be allowed to create the process. And whenever count of processes decreases down it will be below 32767

PS: Although this could be project topic, I do not think there could be any use, significant improvement in linux kernel because of this project. So think about this topic only if you want to prove your skills in process management.


2> Something that accelerates the process descriptor finding mechanism from PID

Wednesday, October 31, 2012

UTLK chapter 3 doubts/questions for Process management

Following are the questions/doubts for the newbie reading process management from UTLK. so these questions you might also feel while you are reading UTLK. These could be also asked in any system/linux device driver position interview. I also have given the answers for the same.(If not for any question that means I am working on it and feel free to post your comment)

Also I have written a  separate blog for the same chapter which contains assignments to be done on own to get deep insights of the linux process management real kernel code. After doing these assignment you will fill comfortable with the linux process and their kernel programming.

At the end of question I have mentioned the page number from UTLK while reading which I got the question in my mind. So these may change edition to edition. I am using 3rd edition, which starts 3rd chapter at 79pg.

  1. How to determine whether two processes share same address space?(pg 79)
  2. If you get to the process descriptor of two processes (mainly parent-child or two threads having same parent-siblings)then as threads share address space for code (text section) you could see that their cs(codesegment) descriptor index is same
  3. How does two threads share data among them using address space sharing?(pg 80)
  4. What are the conditions under which  process in  TASK_UNINTERRUPTIBLE state resumes the execution?(pg81)
  5. If process opens a device file, corresponding device driver will search for the corresponding device, then device driver runs on behalf of process or as a separate kernel process?(pg 82)
  6. Which process can call wait(), wait4() on other process to be in zombie state, only parent of process or any other process? How does race condition occurs while changing process from zombie to dead by multiple threads?
  7. What catastrophic events could happen if changing process state macros eg set_task_state, set_current_state   are not atomic?(pg 83)
  8. As the new process has pid which is just +1 to the old pid, there are chances that if admin does   does slight typo mistake then wrong process would get killed. So what majors could be taken so that this does not happen? also it should not break the assumption that new process has pid greater than the old process. (pg 84). (hypothetical question)
  9. What happens when no more pid number is available to allocate a new process?
  10. Process in kernel code is referred by pointer to its process descriptor. How it has advantage over referring it by pid as we do in user space programming?
  11. Can we change maximum limit on pid? 
  12. Is there limit on process user can create? if yes how to change it?
  13. What are the system calls to which all processes in same thread group react when called once by the tpid( or id of thread group owner process)?
  14. If a process calls wait on other process id, which is a thread group id, does calling process waits till all processes finish execution and become zombie?
  15. How deep function call in kernel would be?
  16. What happenes when kernel stack for some process running in kernel mode is overflowed?
  17. How to check whether kernel mode stack is empty while returning to the userspace? Does every-time new 8kb kernel mode stack is allocated? 
  18. Kernel stack could be represented by a union thread_union { struct thread_info thread info; unsigned long stack[2048]; }, so kernel stack is actual segment or a part of memory in some another segment? if memory, how it is used as a segment to store function call stack?
  19. From where Kalloc allocated memory? (8K stack contains thread_info on other side and not heap)
  20. Where does kernel stack pointer is saved? Does kernel stack is immediately freed while process returns to userspace?
  21. Where does kernel stack limit is stored?
  22. what is use of bitmap for which run queue list is empty in prio_array_t data structure?

Monday, September 24, 2012

UTLK chapter 3 Process management: self study and extra readings

Hi all,

I have listed some points which should be taken for extra reading and could get you deep into process management



  1. Read more about the TASK_TRACED process state and how each signal sent by the debugger causes program to be in TASK_TRACED.
  2. How does kernel use other stacks in case of 4KB stack when  deeply nested interrupt/exception calls are made?
  3. How does process switching from user to kernel mode changes esp.

UTLK chapter 3 Process management: Assignements

Following are the assignments one can do to get more hands on linux kernel process management. They will give you actual experience of things. Will make to browse through kernel code and process management structures which will help you drastically later when you will thing about the project ideas and in implementation phase.

Assignments:
  1. Write a module to show two siblings(threads) share same address space?
  2. Change max_pid by editing /proc/sys/kernel/pid_max. And write down a module and user space program to test whether changed limit has been applied or not. ps: Do we need to reboot the machine to get this modified limit applied. Also see whether there is limit on process creation per user, so any user could not create large number processes.


Project topics.
How to decide process 

Saturday, September 1, 2012

Initial draft: why me working on Linux process management

From long time ago, when I started working on linux kernel, I had wish to linux process management.
I started reading from book called Linux kernel development by Robert Love. This book contains the chapter process management chapter first. When I started reading this chapter, I subsequently started to write some kernel modules having IOCTL interfaces. As things were working as I coded I got interested in process management. But I had to leave processes behind due to file systems. But I would not have regret if I would have learnt linux file system concepts completely. I do accept that although my final year engineering project was in file systems, except big picture of file systems and VFS I hardly know anything about linux EXT3, EXT4 file systems. Later after completing graduation I should have tried to learn the linux process management completely. I tried, but my efforts were discrete. The only thing which made my mind to try read and know process management repetedly after several failures of knowing it was "Con Kolivas: Australian anesthetist who written linux scheduler as fun in spare time". Later I got interested because his brain fuck scheduler was experimental scheduler in Android.I hardly could read 3rd chapter from LKD completely. But now I am feeling shame on me. So this time I have decided to get through the process management and spend my later time as a Linux process management monk. nice, i will rename my blogs name as a linuxprocessmonk. Hope I will get through this and could help lot of people, give back through kernel as well as kernelnewbies mailing list. Thanks for reading ...... :) will see you soon on mailing list.