SlideShare une entreprise Scribd logo
1  sur  56
Télécharger pour lire hors ligne
CS5460/6460: Operating Systems
Lecture 16: Midterm recap, sample
questions
Anton Burtsev
February, 2014
Describe the x86 address translation pipeline
(draw figure), explain stages.
What is the linear address? What address is in
the registers, e.g., in %eax?
Logical and linear addresses
● Segment selector (16 bit) + offset (32 bit)
What segments do the following instructions
use? push, jump, mov
Describe the linear to physical address
translation with the paging mechanism (use
provided diagram, mark and explain the steps).
Page translation
Page translation
Page directory entry (PDE)
● 20 bit address of the page table
● Pages 4KB each, we need 1M to cover 4GB
● R/W – writes allowed?
● To a 4MB region controlled by this entry
● U/S – user/supervisor
● If 0 – user-mode access is not allowed
● A – accessed
Page translation
Page table entry (PTE)
● 20 bit address of the 4KB page
● Pages 4KB each, we need 1M to cover 4GB
● R/W – writes allowed?
● To a 4KB page
● U/S – user/supervisor
● If 0 user-mode access is not allowed
● A – accessed
● D – dirty – software has written to this page
Page translation
Describe the steps and data structures involved
into a user to kernel transition (draw diagrams)
Interrupt path
What segment is specified in the interrupt
descriptor? Why?
Interrupt descriptor
● Interrupt gate disables
interrupts
● Clears the IF flag in
EFLAGS register
● Trap gate doesn't
● IF flag is unchanged
Which stack is used for execution of an
interrupt handler? How does hardware find it?
Why does xv6 uses 4MB pages for the first
page table during boot?
First page table
Describe organization of the memory allocator
in xv6?
Physical page allocator
Describe how a per-CPU variables can be
stored?
swtch in xv6 doesn’t explicitly save and restore
all fields of struct context. Why is it okay that
swtch doesn’t contain any code that saves
%eip?
Stack inside swtch()
Describe how does RCU work?
Read copy update
● Goal: remove “cat” from the
list
● There might be some readers
of “cat”
● Idea: control the pointer
dereference
● Make it atomic
Read copy update (2)
● Remove “cat”
● Update the “boa” pointer
● All subsequent reader will get
“gnu” as boa->next
Read copy update (2)
● Wait for all readers to finish
● synchronize_rcu()
Read copy update (3)
● Readers finished
● Safe to deallocate “cat”
Read copy update (4)
● New state of the list
Under what conditions RCU is a good idea?
In the following piece of code explain the use of
memory barriers?
Reference counting is a potential scalability
bottleneck, what can be done to improve it?
Reference counting is a potential scalability
bottleneck, what can be done to improve it?
● Sloppy counters
Why O(1) is really O(1)?
Why O(1) is really O(1)?
● Hint: analyze all operations and explain why
they are constant.
Alyssa runs xv6 on a machine with 8 processors and 8
processes. Each process calls sbrk (3451) continuously,
growing and shrinking its address space. Alyssa
measures the number of sbrks per second and notices
that 8 processes achieve the same total throughput as 1
process, even though each process runs on a different
processor. She profiles the xv6 kernel while running her
processes and notices that most execution time is spent
in kalloc (2838) and kfree (2815), though little is spent in
memset. Why is the throughput of 8 processes the same
as that of 1 process?
kalloc(void)
{
struct run *r;
if(kmem.use_lock)
acquire(&kmem.lock);
r = kmem.freelist;
if(r)
kmem.freelist = r− >next;
if(kmem.use_lock)
release(&kmem.lock);
return (char*)r;
}
kfree(char *v) {
struct run *r;
memset(v, 1, PGSIZE);
if(kmem.use_lock)
acquire(&kmem.lock);
r = (struct run*)v;
r− >next = kmem.freelist;
kmem.freelist = r;
if(kmem.use_lock)
release(&kmem.lock);
}
What can be done to improve performance?
Suppose you wanted to change the system call
interface in xv6 so that, instead of returning the
system call result in EAX, the kernel pushed the
result on to the user space stack. Fill in the
code below to implement this. For the purposes
of this question, you can assume that the user
stack pointer points to valid memory.
3374 void
3375 syscall(void)
3376 {
3377 int num;
3378
3379 num = proc− >tf− >eax;
3380 if(num > 0 && num < NELEM(syscalls) && syscalls[num]) {
3381 proc− >tf− >eax = syscalls[num]();
3382 } else {
3383 cprintf("%d %s: unknown sys call %dn",
3384 proc− >pid, proc− >name, num);
3385 proc− >tf− >eax = − 1;
3386 }
3387 }
3374 void
3375 syscall(void)
3376 {
3377 int num;
3378
3379 num = proc− >tf− >eax;
3380 if(num > 0 && num < NELEM(syscalls) && syscalls[num]) {
3381 // proc− >tf− >eax = syscalls[num]();
proc->tf->esp -= 4;
*(int*)ptoc->tf->esp = syscalls[num]();
3382 } else {
3383 cprintf("%d %s: unknown sys call %dn",
3384 proc− >pid, proc− >name, num);
3385 // proc− >tf− >eax = − 1;
proc->tf->esp -= 4;
*(int*)ptoc->tf->esp = -1;
3386 }
3387 }
1474 acquire(struct spinlock *lk)
1475 {
1476 pushcli();
1477 if(holding(lk))
1478 panic("acquire");
...
1483 while(xchg(&lk− >locked, 1) != 0)
1484 ;
...
1489 }
Why does acquire disable
interrupts?
1474 acquire(struct spinlock *lk)
1475 {
1476 pushcli();
1477 if(holding(lk))
1478 panic("acquire");
...
1483 while(xchg(&lk− >locked, 1) != 0)
1484 ;
...
1489 }
What would go wrong if you
replaced pushcli() with just cli(),
and popcli() with just sti()?
Explain why it would be awkward for xv6 to give
a process different data and stack segments
(i.e. have DS and SS refer to descriptors with
different BASE fields).
Thank you!

Contenu connexe

Similaire à CS5460/6460: Operating Systems Lecture 16 Midterm recap sample questions

Introduction to Processor Design and ARM Processor
Introduction to Processor Design and ARM ProcessorIntroduction to Processor Design and ARM Processor
Introduction to Processor Design and ARM ProcessorDarling Jemima
 
Berkeley Packet Filters
Berkeley Packet FiltersBerkeley Packet Filters
Berkeley Packet FiltersKernel TLV
 
Streaming huge databases using logical decoding
Streaming huge databases using logical decodingStreaming huge databases using logical decoding
Streaming huge databases using logical decodingAlexander Shulgin
 
Demystify eBPF JIT Compiler
Demystify eBPF JIT CompilerDemystify eBPF JIT Compiler
Demystify eBPF JIT CompilerNetronome
 
Part III: Assembly Language
Part III: Assembly LanguagePart III: Assembly Language
Part III: Assembly LanguageAhmed M. Abed
 
Unit II Arm 7 Introduction
Unit II Arm 7 IntroductionUnit II Arm 7 Introduction
Unit II Arm 7 IntroductionDr. Pankaj Zope
 
(Open) MPI, Parallel Computing, Life, the Universe, and Everything
(Open) MPI, Parallel Computing, Life, the Universe, and Everything(Open) MPI, Parallel Computing, Life, the Universe, and Everything
(Open) MPI, Parallel Computing, Life, the Universe, and EverythingJeff Squyres
 
(8) cpp stack automatic_memory_and_static_memory
(8) cpp stack automatic_memory_and_static_memory(8) cpp stack automatic_memory_and_static_memory
(8) cpp stack automatic_memory_and_static_memoryNico Ludwig
 
Revelation pyconuk2016
Revelation pyconuk2016Revelation pyconuk2016
Revelation pyconuk2016Sarah Mount
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAAiman Hud
 
Pragmatic Optimization in Modern Programming - Demystifying the Compiler
Pragmatic Optimization in Modern Programming - Demystifying the CompilerPragmatic Optimization in Modern Programming - Demystifying the Compiler
Pragmatic Optimization in Modern Programming - Demystifying the CompilerMarina Kolpakova
 
Addressing modes (detailed data path)
Addressing modes (detailed data path)Addressing modes (detailed data path)
Addressing modes (detailed data path)Mahesh Kumar Attri
 
Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086Shehrevar Davierwala
 
pdfslide.net_morris-mano-ppt.ppt
pdfslide.net_morris-mano-ppt.pptpdfslide.net_morris-mano-ppt.ppt
pdfslide.net_morris-mano-ppt.pptSaurabhPorwal14
 
Addressing Modes
Addressing ModesAddressing Modes
Addressing ModesMayank Garg
 
Finding Xori: Malware Analysis Triage with Automated Disassembly
Finding Xori: Malware Analysis Triage with Automated DisassemblyFinding Xori: Malware Analysis Triage with Automated Disassembly
Finding Xori: Malware Analysis Triage with Automated DisassemblyPriyanka Aash
 

Similaire à CS5460/6460: Operating Systems Lecture 16 Midterm recap sample questions (20)

Introduction to Processor Design and ARM Processor
Introduction to Processor Design and ARM ProcessorIntroduction to Processor Design and ARM Processor
Introduction to Processor Design and ARM Processor
 
nasm_final
nasm_finalnasm_final
nasm_final
 
Berkeley Packet Filters
Berkeley Packet FiltersBerkeley Packet Filters
Berkeley Packet Filters
 
Streaming huge databases using logical decoding
Streaming huge databases using logical decodingStreaming huge databases using logical decoding
Streaming huge databases using logical decoding
 
Cao 2012
Cao 2012Cao 2012
Cao 2012
 
Demystify eBPF JIT Compiler
Demystify eBPF JIT CompilerDemystify eBPF JIT Compiler
Demystify eBPF JIT Compiler
 
Part III: Assembly Language
Part III: Assembly LanguagePart III: Assembly Language
Part III: Assembly Language
 
Unit II Arm 7 Introduction
Unit II Arm 7 IntroductionUnit II Arm 7 Introduction
Unit II Arm 7 Introduction
 
(Open) MPI, Parallel Computing, Life, the Universe, and Everything
(Open) MPI, Parallel Computing, Life, the Universe, and Everything(Open) MPI, Parallel Computing, Life, the Universe, and Everything
(Open) MPI, Parallel Computing, Life, the Universe, and Everything
 
(8) cpp stack automatic_memory_and_static_memory
(8) cpp stack automatic_memory_and_static_memory(8) cpp stack automatic_memory_and_static_memory
(8) cpp stack automatic_memory_and_static_memory
 
Revelation pyconuk2016
Revelation pyconuk2016Revelation pyconuk2016
Revelation pyconuk2016
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
Design
DesignDesign
Design
 
Pragmatic Optimization in Modern Programming - Demystifying the Compiler
Pragmatic Optimization in Modern Programming - Demystifying the CompilerPragmatic Optimization in Modern Programming - Demystifying the Compiler
Pragmatic Optimization in Modern Programming - Demystifying the Compiler
 
Addressing modes (detailed data path)
Addressing modes (detailed data path)Addressing modes (detailed data path)
Addressing modes (detailed data path)
 
Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086
 
Lecture9
Lecture9Lecture9
Lecture9
 
pdfslide.net_morris-mano-ppt.ppt
pdfslide.net_morris-mano-ppt.pptpdfslide.net_morris-mano-ppt.ppt
pdfslide.net_morris-mano-ppt.ppt
 
Addressing Modes
Addressing ModesAddressing Modes
Addressing Modes
 
Finding Xori: Malware Analysis Triage with Automated Disassembly
Finding Xori: Malware Analysis Triage with Automated DisassemblyFinding Xori: Malware Analysis Triage with Automated Disassembly
Finding Xori: Malware Analysis Triage with Automated Disassembly
 

Dernier

W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceanilsa9823
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 

Dernier (20)

W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 

CS5460/6460: Operating Systems Lecture 16 Midterm recap sample questions

  • 1. CS5460/6460: Operating Systems Lecture 16: Midterm recap, sample questions Anton Burtsev February, 2014
  • 2. Describe the x86 address translation pipeline (draw figure), explain stages.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11. What is the linear address? What address is in the registers, e.g., in %eax?
  • 12. Logical and linear addresses ● Segment selector (16 bit) + offset (32 bit)
  • 13. What segments do the following instructions use? push, jump, mov
  • 14. Describe the linear to physical address translation with the paging mechanism (use provided diagram, mark and explain the steps).
  • 17. Page directory entry (PDE) ● 20 bit address of the page table ● Pages 4KB each, we need 1M to cover 4GB ● R/W – writes allowed? ● To a 4MB region controlled by this entry ● U/S – user/supervisor ● If 0 – user-mode access is not allowed ● A – accessed
  • 19. Page table entry (PTE) ● 20 bit address of the 4KB page ● Pages 4KB each, we need 1M to cover 4GB ● R/W – writes allowed? ● To a 4KB page ● U/S – user/supervisor ● If 0 user-mode access is not allowed ● A – accessed ● D – dirty – software has written to this page
  • 21. Describe the steps and data structures involved into a user to kernel transition (draw diagrams)
  • 23. What segment is specified in the interrupt descriptor? Why?
  • 25. ● Interrupt gate disables interrupts ● Clears the IF flag in EFLAGS register ● Trap gate doesn't ● IF flag is unchanged
  • 26. Which stack is used for execution of an interrupt handler? How does hardware find it?
  • 27. Why does xv6 uses 4MB pages for the first page table during boot?
  • 29. Describe organization of the memory allocator in xv6?
  • 31. Describe how a per-CPU variables can be stored?
  • 32.
  • 33. swtch in xv6 doesn’t explicitly save and restore all fields of struct context. Why is it okay that swtch doesn’t contain any code that saves %eip?
  • 35. Describe how does RCU work?
  • 36. Read copy update ● Goal: remove “cat” from the list ● There might be some readers of “cat” ● Idea: control the pointer dereference ● Make it atomic
  • 37. Read copy update (2) ● Remove “cat” ● Update the “boa” pointer ● All subsequent reader will get “gnu” as boa->next
  • 38. Read copy update (2) ● Wait for all readers to finish ● synchronize_rcu()
  • 39. Read copy update (3) ● Readers finished ● Safe to deallocate “cat”
  • 40. Read copy update (4) ● New state of the list
  • 41. Under what conditions RCU is a good idea?
  • 42. In the following piece of code explain the use of memory barriers?
  • 43. Reference counting is a potential scalability bottleneck, what can be done to improve it?
  • 44. Reference counting is a potential scalability bottleneck, what can be done to improve it? ● Sloppy counters
  • 45. Why O(1) is really O(1)?
  • 46. Why O(1) is really O(1)? ● Hint: analyze all operations and explain why they are constant.
  • 47. Alyssa runs xv6 on a machine with 8 processors and 8 processes. Each process calls sbrk (3451) continuously, growing and shrinking its address space. Alyssa measures the number of sbrks per second and notices that 8 processes achieve the same total throughput as 1 process, even though each process runs on a different processor. She profiles the xv6 kernel while running her processes and notices that most execution time is spent in kalloc (2838) and kfree (2815), though little is spent in memset. Why is the throughput of 8 processes the same as that of 1 process?
  • 48. kalloc(void) { struct run *r; if(kmem.use_lock) acquire(&kmem.lock); r = kmem.freelist; if(r) kmem.freelist = r− >next; if(kmem.use_lock) release(&kmem.lock); return (char*)r; } kfree(char *v) { struct run *r; memset(v, 1, PGSIZE); if(kmem.use_lock) acquire(&kmem.lock); r = (struct run*)v; r− >next = kmem.freelist; kmem.freelist = r; if(kmem.use_lock) release(&kmem.lock); }
  • 49. What can be done to improve performance?
  • 50. Suppose you wanted to change the system call interface in xv6 so that, instead of returning the system call result in EAX, the kernel pushed the result on to the user space stack. Fill in the code below to implement this. For the purposes of this question, you can assume that the user stack pointer points to valid memory.
  • 51. 3374 void 3375 syscall(void) 3376 { 3377 int num; 3378 3379 num = proc− >tf− >eax; 3380 if(num > 0 && num < NELEM(syscalls) && syscalls[num]) { 3381 proc− >tf− >eax = syscalls[num](); 3382 } else { 3383 cprintf("%d %s: unknown sys call %dn", 3384 proc− >pid, proc− >name, num); 3385 proc− >tf− >eax = − 1; 3386 } 3387 }
  • 52. 3374 void 3375 syscall(void) 3376 { 3377 int num; 3378 3379 num = proc− >tf− >eax; 3380 if(num > 0 && num < NELEM(syscalls) && syscalls[num]) { 3381 // proc− >tf− >eax = syscalls[num](); proc->tf->esp -= 4; *(int*)ptoc->tf->esp = syscalls[num](); 3382 } else { 3383 cprintf("%d %s: unknown sys call %dn", 3384 proc− >pid, proc− >name, num); 3385 // proc− >tf− >eax = − 1; proc->tf->esp -= 4; *(int*)ptoc->tf->esp = -1; 3386 } 3387 }
  • 53. 1474 acquire(struct spinlock *lk) 1475 { 1476 pushcli(); 1477 if(holding(lk)) 1478 panic("acquire"); ... 1483 while(xchg(&lk− >locked, 1) != 0) 1484 ; ... 1489 } Why does acquire disable interrupts?
  • 54. 1474 acquire(struct spinlock *lk) 1475 { 1476 pushcli(); 1477 if(holding(lk)) 1478 panic("acquire"); ... 1483 while(xchg(&lk− >locked, 1) != 0) 1484 ; ... 1489 } What would go wrong if you replaced pushcli() with just cli(), and popcli() with just sti()?
  • 55. Explain why it would be awkward for xv6 to give a process different data and stack segments (i.e. have DS and SS refer to descriptors with different BASE fields).