fork_init

  1. void __init fork_init(unsigned long mempages)
  2. {
  3. #ifndef CONFIG_ARCH_TASK_STRUCT_ALLOCATOR
  4. #ifndef ARCH_MIN_TASKALIGN
  5. #define ARCH_MIN_TASKALIGN L1_CACHE_BYTES
  6. #endif
  7. /* create a slab on which task_structs can be allocated */
  8. task_struct_cachep =
  9. kmem_cache_create("task_struct", sizeof(struct task_struct),
  10. ARCH_MIN_TASKALIGN, SLAB_PANIC | SLAB_NOTRACK, NULL);
  11. #endif
  12.  
  13. /* do the arch specific task caches init */
  14. arch_task_cache_init();
  15.  
  16. /*
  17. * The default maximum number of threads is set to a safe
  18. * value: the thread structures can take up at most half
  19. * of memory.
  20. */
  21. max_threads = mempages / (8 * THREAD_SIZE / PAGE_SIZE);
  22.  
  23. /*
  24. * we need to allow at least 20 threads to boot a system
  25. */
  26. if (max_threads < 20)
  27. max_threads = 20;
  28.  
  29. init_task.signal->rlim[RLIMIT_NPROC].rlim_cur = max_threads/2;
  30. init_task.signal->rlim[RLIMIT_NPROC].rlim_max = max_threads/2;
  31. init_task.signal->rlim[RLIMIT_SIGPENDING] =
  32. init_task.signal->rlim[RLIMIT_NPROC];
  33. }
  34.  
Programming language: 
C