Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction on FreeBSD Operating System

Similar presentations

Presentation on theme: "Introduction on FreeBSD Operating System"— Presentation transcript:

1 Introduction on FreeBSD Operating System

2 Agenda History and Goals Kernel Services Process Management
Memory Management I/O System Interprocess Communication System Operation Acknowledgments

3 History and Goals History of the UNIX System BSD and Other Systems
The Transition of BSD to Open Source The FreeBSD Development Model

4 History of the UNIX System
Bell Lab invented UNIX in 1969 It was written by C-language It was distributed by source form It can run cheap hardware with advance features CSRG at Berkeley invented BSD in 1979 Virtual memory, demand paging, page replacement Socket interface for TCP/IP Job control, reliable signals, filesystem interface

5 BSD and Other Systems Most features from UNIX
Terminal drivers from TENEX/TOPS-20 Job control from TOPS and MIT’s ITS Memory management from Mach The Influence of the User Community Some packages from other groups comp.bugs.4bsd

6 The Transition of BSD to Open Source
The FreeBSD group was formed in 1993 Supporting the PC architecture only Ease of installation Code started base with 4.4BSD-Lite Current version is FreeBSD5.4 Alpha, Space64, X86 JUNOS is based on FreeBSD4.10

7 The FreeBSD Development Model
Publicly readable source-code control system Developers groups 3000 to 4000 developers They are not permitted to change code Committees 300 to 400 committees They are permitted to change code Core team can do everything

8 Kernel Services FreeBSD Facilities and the Kernel System Calls
Traps and Interrupts Clock Interrupts Memory Management Services Timing Services User, Group and Other Identifiers Resource Services System Operation Services

9 FreeBSD Facilities and the Kernel
Kernel Provide 4 basic facilities: process, filesystem, communication, system startup Kernel has been organized to the follow: Basic kernel facilities: timer, system-clock handling, descriptor management, process management Memory management: paging and swapping Generic system interface: the I/O, control, I/O descriptors The filesystem: files, directories, pathname translation, i/O buffer management Interprocess-communication: sockets

10 FreeBSD Facilities and the Kernel
Low-level system-startup actions Trap and fault handling Low-level manipulation of the run-time context of a process Configuration and initialization of hardware devices Run-time support for I/O devices

11 System Calls System calls provide a layer between the hardware and user-space processes Provides an abstracted hardware interface for user-space Ensure system security and stability A single common layer between user-space and the rest of the system allows the multi-processes Syscall handling: Verify the parameter to the system call Call a kernel routine that implements the system call Result handling: errno

12 Traps and Interrupts Traps occur synchronously for process
Divide by zero, illegal instruction, page fault I/O device Interrupts occur asynchronously Clocks, Console, Ethernet Software Interrupts is doing lower-priority processing for I/O interrupts

13 Clock Interrupts The system is driven by a clock that interrupts at regular intervals which we call tick. Most system tick for FreeBSD is 10ms. hardclock() Increment the current time of day Call softclock() if necessary softclock() Process real-time timer Retransmission of dropped network packets Watchdog timers on peripherals that require monitoring System process-rescheduling event

14 Memory Management Services
Demand paging Copy-on-write mmap() interface for share memory sbrk() for heap allocate

15 Timing Services System Real Time Interval Time for each process
Wakeup timer Profiling timer: kernel and user mode Virtual timer: user mode

16 User, Group and Other Identifiers
User identifier (UID) and Group identifier (GID) set-user-identifier and set-group-identifier, effective uid and effective gid Process Groups and Sessions Each process in the system is associated with a process group The group of processes is referred to as a job A session is a collection of process groups

17 Resource Services Process Priorities: nice value Resource Utilization
The amount of user and system time used by process The memory utilization of process The paging and disk I/O activity of process The number of voluntary and involuntary context switches Resource Limits Filesystem Quotas

18 System Operation Services
Accounting The name of the command that ran The amount of user and system CPU time that was used The average amount of memory used Bootstrapping Shutdown Debugging

19 Process Management Introduction to Process Management Process State
Context Switching Process Scheduling Process Creation and Termination Process Debugging

20 Introduction to Process Management
The definition of Process Design goal for FreeBSD Process management Multiprogramming Fair Scheduling Communication Easy management and debugging

21 Process State The proc structure Process identification: PID and PPID
Scheduling: The process priority, user-mode scheduling priority, recent CPU utilization, and amount of time spent sleeping Process state: SIDL,SRUN,SSLEEP,SSTOP,SZOMB Signal state: Signals pending delivery Tracing Machine state Timers

22 Context Switching Cause of context switching
A process executes for the duration of its time slice A process block for resource The system interrupts the current process Voluntary Context Switching sleep() and wakeup() Synchronization Set-priority-level, spl0, splsoftclock, splnet, …, splhigh

23 Process Scheduling I/O-Bound Versus Processor-Bound
FreeBSD favors I/O bound Multilevel feedback queue Round robin for same queue Calculations of Process Priority p_estcpu: an estimate of the recent CPU utilization of this process p_nice: user-settable weighting factor that ranges from -20 to 20

24 Process Creation and Termination
Parent process and child process fork(), vfork() and rfork() Implementation of fork1() Termination exit() OR signal wait4() and SZOMB

25 Process Debugging ptrace system call Inefficient of ptrace
Read and write address space and registers Intercept signals posted to the process Single step and continue the execution of process Terminate the execution of the process Inefficient of ptrace /proc file system

26 Memory Management Overview of the FreeBSD VM System
Kernel Memory Management Per-Process Resources Shared Memory Process Related Memory Operation The Pager interface Placement and Replacement

27 Overview of the FreeBSD VM System
FreeBSD VM is paging system Three important policies: The fetch policy The placement policy The replacement policy Swapping mmap system call for shared memory

28 Kernel Memory Management
Kernel is permanently mapped into up 1G of every process address space Kernel Maps and Submaps kmem_alloc(), kmem_alloc_pageable(), kmem_free() Kernel malloc Kernel Zone Allocator

29 Per-Process Resources
Vm_map_entry vmspace Vnode/object vm_page Start addr End addr Obj offset Vm_map vm_page Vm_pmap Vnode/object vm_page Start addr End addr Obj offset statistics vm_page Vnode/object vm_page Start addr End addr Obj offset vm_page

30 Shared Memory mmap(caddr_t address, size_t length, int protection, int flags, int fd, off_t offset) munmap mprotect mlock and munlock msync

31 Process Related Memory Operation
Create of a New Process copy-on-write Load a execute file page-on-demand Process manipulation of its address space sbrk, mmap, mprotect Termination of Process

32 The Pager interface Vnode Pager Device Pager Physical-Memory Pager
Handles objects that map files in a filesystem Device Pager Handles objects representing memory-mapped hardware devices Physical-Memory Pager Handles nonpagable memory for System V shm Swap Pager Handles object that map anonymous memory Handles shadow object

33 Placement and Replacement
Page Coloring L1 Cache Coloring L2 Cache Coloring Page Replacement Global least-recently used page Wired, active, inactive, cache, free Swapping

34 I/O System I/O System Overview Devices The Filesystems

35 I/O System Overview Four main kinds of I/Os: filesystem, character-device, block-device, socket interface Devices identified by a major and minor number The Virtual-Filesystem Interface Descriptor Management Services Filesystem-Independent Services Name cache, Buffer management Stackable Filesystems

36 Devices Device Naming and Access Asynchronous I/O
Static device node under /dev DEVFS for dynamical device management Asynchronous I/O aio_read, aio_write Mutliplexing I/O on Descriptors select()

37 The Filesystems Virtual-Filesystem Interface
vnode operation Pathname translation Exported Filesystem Services Name cache and Buffer Management Physical-Filesystem interface Structure of inode Implementation of Filesystem Services

38 Interprocess Communication
SYSV Interprocess communication POSIX b is not implemented in kernel Socket API Network Communication Network Protocols

39 SYSV Interprocess communication
sysv ipc ftok sysv message queue msgget, msgsnd, msgrcv, msgctl sysv semaphore semget, semop, semctl sysv shared memory shmget, shmat, shmdt, shmctl, shmids

40 System Operation Bootstrapping Kernel Initialization
Kernel Module Initialization User-Level Initialization System Shutdown and Autoreboot Configuration, Build and Debugging

41 Bootstrapping BIOS loads boot Commands for boot
boot, autoboot, help, load … Boot loads FreeBSD kernel from BSD filesystem Boot passes the information to kernel Boot need disable mmu and interrupts

42 Kernel Initialization
Setting up the run-time stack Identifying the type of CPU Calculating the amount of physical memory Initializing MMU hardware and Enable the MMU Crafting the hardware context for process 0 Invoking the initial C-base entry point

43 Kernel Module Initialization
Entry point: mi_startup() SYSINIT(name, subsystem,order, function,…) Basic services Kernel Thread Initialization Device Module Initialization Kernel Loadable Modules Interprocess Communication Startup Start Kernel Threads

44 User-Level Initialization
/sbin/init Check consistency of its disk by fsck Single-user mode: /bin/sh and /dev/console Multi-user mode: /etc/rc and /etc/ttys

45 System Shutdown and Autoreboot
reboot system call panic() causes system reboot Three phases for shutdown Shutdown of all services rely to the filesystem Shutdown of the filesystem itself Shutdown other services

46 Configuration, Build and Debugging
make buildkernel KERNCONF=<cfgfile> make installkernel KERNCONF=<cfgfile> Crash dump file /sbin/savecore Using /dev/kmem to talk to kernel

47 Acknowledgements
The Design and Implementation of FreeBSD

Download ppt "Introduction on FreeBSD Operating System"

Similar presentations

Ads by Google