《高级操作系统高级操作系统 (31).pdf》由会员分享,可在线阅读,更多相关《高级操作系统高级操作系统 (31).pdf(16页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、第 6 讲:The Programming Languages of OS第四节:The benefits and costs of writing kernel in a high-level languageIntroduction BiscuitShould we use high-level languagesto build OS kernels?BenefitsEasier to programSimpler concurrency with GCPrevents classes of kernel bugsDownsideBounds,cast,nil-pointer check
2、sReflectionGarbage collection.Introduction BiscuitGoal:measure HLL impactPros:Reduction of bugsSimpler codeCons:HLL safety taxGC CPU and memory overheadGC pause times.Introduction BiscuitMethodologyNone measure HLL impact in a monolithic POSIX kernelBuild new HLL kernel,compare with LinuxIsolate HLL
3、 impact:Same apps,POSIX interface,and monolithic organization.Introduction Biscuit58 syscalls,LOC:28k Go,1.5kassembly(boot,entry/exit)Go-langEasy to call asmCompiled to machine code w/good compilerEasy concurrency&static analysisGCConcurrent mark and sweepStop-the-world pauses of 10s of s.Introducti
4、on Biscuit58 syscalls,LOC:28k Go,1.5kassembly(boot,entry/exit)BiscuitMulticoreThreadsJournaled FS(7k LOC)Virtual memory(2k LOC)TCP/IP stack(5k LOC)Drivers:AHCI and Intel 10G NIC(3k LOC).Introduction Biscuit58 syscalls,LOC:28k Go,1.5kassembly(boot,entry/exit)Many implementation puzzles in BiscuitInte
5、rruptsThreadsKernel threads are lightweightRuntime on bare-metalHeap exhaustion(Surprising)etc.Introduction Biscuit58 syscalls,LOC:28k Go,1.5kassembly(boot,entry/exit)Cant allocate heap memory=nothing worksAll kernels face this problem.Introduction Biscuit58 syscalls,LOC:28k Go,1.5kassembly(boot,ent
6、ry/exit)Strawman 1:Wait for memory in allocator?May deadlock!Strawman 2:Check/handle allocation failure,like Ckernels?Difficult to get rightCant!Go doesnt expose failed allocationsand implicitly allocatesBoth cause problems for Linux;see“too small to fail”rule.Introduction Biscuit58 syscalls,LOC:28k
7、 Go,1.5kassembly(boot,entry/exit)ReservationsHLL easy to analyzeTool computes reservation via escape analysis three days of expert effort to apply tool.Introduction Biscuit58 syscalls,LOC:28k Go,1.5kassembly(boot,entry/exit)BISCUIT adopted many Linux optimizations:large pages for kernel textper-CPU
8、NIC transmit queuesRCU-like directory cacheconcurrent FS transactionspad structs to remove false sharingGood OS performance more about optimizations,lessabout HLL.Introduction Biscuit58 syscalls,LOC:28k Go,1.5kassembly(boot,entry/exit)Eval:Should we use high-level languages to build OSkernels?Did BI
9、SCUIT benefit from HLL features?Is BISCUIT performance in the same league asLinux?What is the breakdown of HLL tax?What is the performance cost of Go compared to C?.Introduction Biscuit58 syscalls,LOC:28k Go,1.5kassembly(boot,entry/exit)Eval:Qualitative benefits of HLL featuresGCed allocationdefermu
10、lti-valued returnclosuresmapsInspected fixes for all publicly-available execute codeCVEs in Linux kernel for 2017panic likely better than malicious code execution.Introduction BiscuitBiscuit and Linux in the same leaguethe breakdown of HLL tax in Biscuit.Introduction BiscuitC is 15%fasterPrologue/sa
11、fety-checks 16%more instructionsThe HLL worked well for kernel developmentPerformance is paramount use C(up to 15%)Minimize memory use use C(mem.budget,GC cost)Safety is paramount use HLL(40 CVEs stopped)Performance merely important use HLL(pay 15%,memory).ReferencesMultiprogramming a 64 kB Computer Safely and Efficiently,SOSP 2017The benefits and costs of writing a POSIX kernel in a high-level language,OSDI 2018.