11 - Linux ProcessesOutlineProcess Address SpaceTask StructMore ReadingLinux Clone Syscall/procAnnouncementsReading: MOS 10.3.1, 10.3.2, 10.3.3; LDD 2Process Address SpaceKernel address space in Linux is NOT separate.(Apologies for stating otherwise in previous lecture)The process address space is split into user- andkernel-space.Kernel is mapped into same virtual memory rangefor every process.Kernel execution contexts must be maintainedseparately for each process While in user-mode, access to kernel-mode addressrange is denied by MMU.It is possible for kernel to live in differentaddress space, but split space makes some thingseasier (like copying user data)Linux represents a process as a task.Equivalent of PCB:Field categories:Notable fields:Kernel can access the calling process via:User-mode processes can get information aboutother processes through the special /proc filesystem in Linux.Recap: fork & execFork is part of the POSIX standard for creatingprocesses.Clone creates tasks, which can represent eitherprocesses or threads depending on the amount ofsharing.Linux will assign a PID based on parameters.share nothing = forkshare everything = create threadLinux creates new tasks with the clone syscall.Some information from task_struct available via:See #proc in Linux Filesystem HierarchyA special macro to get the pointer to thecurrent user-space process.generalization of forknot part of POSIX, not portable!Starts executing function instead of full copy ofprocess.Execution can optionally use new stack.sharing_flags describes amount of sharingbetween caller and callee (parent and child)Source: Task is a generalization of an execution context.Linux uses tasks to represent threads as well.Scheduling params (priority, CPU time, etc.)struct thread_info thread_infoMemory image (text, stack, heap, etc.)unsigned int __stateSignalsvoid *stackCPU registersunsigned int flagsSystem call state (parameters, result, etc.)int prio, static_prio, normal_priostruct mm_struct *mmpid_t pidstruct task_struct *parentu64 utime, stime, start_timechar comm[TASK_COMM_LEN]File descriptor tableAccounting (user time, system time, limits, etc.)Kernel stack (per-process)Miscellaneous (PID, process state, etc.)pointer to memory management structname of loaded program in processDuring the context switch, access permissionschange with kernel-mode entry, and kernel-modeaddress range is accessible.Task StructLinux Clone SyscallPA 2 autograder almost done.No in-person lecture on Tuesday.I willl post a recording on Monday.1)2)3)---------------------------------00000000_00000000ffff8000_0000000000007fff_ffffefffffffffff_ffffffffuser-spacevirtual memory(switched)kernel-spacevirtual memory(shared)...see Linux mm documentationsee Lorenzo Stoakes's notestask_structcurrentinclude/linux/sched.harch/x86/include/asm/current.hforkclonekernel_clonecopy_processwake_up_new_tasksource code:/proc `-- <PID> |-- status # process status info |-- comm # program name |-- exe # program symlink |-- maps # mapped memory ...child_id = clone(function, stack_ptr, sharing_flags, arg);MOS Figure 10-8MOS Figure 10-9Bothandcallcallsdoes memory copiesputs process in ready queuelinux-kernel-labs - Processeslinux-kernel-labs - Address SpaceLorenzo Stoakes - VM Notes: Process Address SpaceLorenzo Stoakes - MM Notes: Virtual memory layoutLinux Kernel Docs - Memory Management DocumentationLinux Kernel Docs - Process Addressesandkernel_clonecopy_processwake_up_new_task