kernel implementations i - computer science and...
TRANSCRIPT
![Page 1: Kernel Implementations I - Computer Science and Engineeringweb.cse.ohio-state.edu/...sw2/...Implementations-I.pdfKernel Implementations I. 15 January 2019 OSU CSE 1. So, What’s Inside](https://reader033.vdocuments.site/reader033/viewer/2022060508/5f2390410b6c376f085521c6/html5/thumbnails/1.jpg)
Kernel Implementations I
15 January 2019 OSU CSE 1
![Page 2: Kernel Implementations I - Computer Science and Engineeringweb.cse.ohio-state.edu/...sw2/...Implementations-I.pdfKernel Implementations I. 15 January 2019 OSU CSE 1. So, What’s Inside](https://reader033.vdocuments.site/reader033/viewer/2022060508/5f2390410b6c376f085521c6/html5/thumbnails/2.jpg)
So, What’s Inside the Computer?
• Consider any popular video game, e.g., Nintendo Wii bowling
• Are there bowling balls and bowling pins inside the game console’s computer?
15 January 2019 OSU CSE 2
![Page 3: Kernel Implementations I - Computer Science and Engineeringweb.cse.ohio-state.edu/...sw2/...Implementations-I.pdfKernel Implementations I. 15 January 2019 OSU CSE 1. So, What’s Inside](https://reader033.vdocuments.site/reader033/viewer/2022060508/5f2390410b6c376f085521c6/html5/thumbnails/3.jpg)
• Consider any popular video game, e.g., Nintendo Wii bowling
• Are there bowling balls and bowling pins inside the game console’s computer?– Of course not!
• What’s really inside the computer, then, that makes bowling-like behavior?
15 January 2019 OSU CSE 3
So, What’s Inside the Computer?
![Page 4: Kernel Implementations I - Computer Science and Engineeringweb.cse.ohio-state.edu/...sw2/...Implementations-I.pdfKernel Implementations I. 15 January 2019 OSU CSE 1. So, What’s Inside](https://reader033.vdocuments.site/reader033/viewer/2022060508/5f2390410b6c376f085521c6/html5/thumbnails/4.jpg)
• Consider any popular video game, e.g., Nintendo Wii bowling
• Are there bowling balls and bowling pins inside the game console computer?– Of course not!
• What’s really inside the computer, then, that makes bowling-like behavior?
15 January 2019 OSU CSE 4
A thought experiment:What dynamic behavior
would you see if you had a magical magnifying glass and could see inside the computer at any level of detail while it’s running?
So, What’s Inside the Computer?
![Page 5: Kernel Implementations I - Computer Science and Engineeringweb.cse.ohio-state.edu/...sw2/...Implementations-I.pdfKernel Implementations I. 15 January 2019 OSU CSE 1. So, What’s Inside](https://reader033.vdocuments.site/reader033/viewer/2022060508/5f2390410b6c376f085521c6/html5/thumbnails/5.jpg)
A Useful Metaphor
15 January 2019 OSU CSE 5
![Page 6: Kernel Implementations I - Computer Science and Engineeringweb.cse.ohio-state.edu/...sw2/...Implementations-I.pdfKernel Implementations I. 15 January 2019 OSU CSE 1. So, What’s Inside](https://reader033.vdocuments.site/reader033/viewer/2022060508/5f2390410b6c376f085521c6/html5/thumbnails/6.jpg)
A Tower of Abstractions
• Bowling pins?• Vectors?• Numbers?• Bits?• Voltages?• Electrons?• ???
15 January 2019 OSU CSE 6
![Page 7: Kernel Implementations I - Computer Science and Engineeringweb.cse.ohio-state.edu/...sw2/...Implementations-I.pdfKernel Implementations I. 15 January 2019 OSU CSE 1. So, What’s Inside](https://reader033.vdocuments.site/reader033/viewer/2022060508/5f2390410b6c376f085521c6/html5/thumbnails/7.jpg)
A Tower of Abstractions
• Bowling pins?• Vectors?• Numbers?• Bits?• Voltages?• Electrons?• ???
15 January 2019 OSU CSE 7
These are all “just” mathematical models, i.e.,
abstractions used to explain and predict behavior.
![Page 8: Kernel Implementations I - Computer Science and Engineeringweb.cse.ohio-state.edu/...sw2/...Implementations-I.pdfKernel Implementations I. 15 January 2019 OSU CSE 1. So, What’s Inside](https://reader033.vdocuments.site/reader033/viewer/2022060508/5f2390410b6c376f085521c6/html5/thumbnails/8.jpg)
A Tower of Abstractions
• Bowling pins?• Vectors?• Numbers?• Bits?• Voltages?• Electrons?• ???
15 January 2019 OSU CSE 8
Domain: PhysicsThese models are supposed to match physical reality, and are discarded if they do not; limited by the physical world.
![Page 9: Kernel Implementations I - Computer Science and Engineeringweb.cse.ohio-state.edu/...sw2/...Implementations-I.pdfKernel Implementations I. 15 January 2019 OSU CSE 1. So, What’s Inside](https://reader033.vdocuments.site/reader033/viewer/2022060508/5f2390410b6c376f085521c6/html5/thumbnails/9.jpg)
A Tower of Abstractions
• Bowling pins?• Vectors?• Numbers?• Bits?• Voltages?• Electrons?• ???
15 January 2019 OSU CSE 9
Domain: ComputingThese models are entirely artificial (need not match
physical reality); limited only by the creativity of the
software engineer.
![Page 10: Kernel Implementations I - Computer Science and Engineeringweb.cse.ohio-state.edu/...sw2/...Implementations-I.pdfKernel Implementations I. 15 January 2019 OSU CSE 1. So, What’s Inside](https://reader033.vdocuments.site/reader033/viewer/2022060508/5f2390410b6c376f085521c6/html5/thumbnails/10.jpg)
A Tower of Abstractions
• Bowling pins• Vectors• Numbers• Bits• Voltages• Electrons• ???
15 January 2019 OSU CSE 10
![Page 11: Kernel Implementations I - Computer Science and Engineeringweb.cse.ohio-state.edu/...sw2/...Implementations-I.pdfKernel Implementations I. 15 January 2019 OSU CSE 1. So, What’s Inside](https://reader033.vdocuments.site/reader033/viewer/2022060508/5f2390410b6c376f085521c6/html5/thumbnails/11.jpg)
A Tower of Abstractions
• Bowling pins• Vectors• Numbers• Bits• Voltages• Electrons• ???
15 January 2019 OSU CSE 11
Numbers may be built on top of bits…
![Page 12: Kernel Implementations I - Computer Science and Engineeringweb.cse.ohio-state.edu/...sw2/...Implementations-I.pdfKernel Implementations I. 15 January 2019 OSU CSE 1. So, What’s Inside](https://reader033.vdocuments.site/reader033/viewer/2022060508/5f2390410b6c376f085521c6/html5/thumbnails/12.jpg)
A Tower of Abstractions
• Bowling pins• Vectors• Numbers• Bits• Voltages• Electrons• ???
15 January 2019 OSU CSE 12
Bits may be built on top of voltages…
![Page 13: Kernel Implementations I - Computer Science and Engineeringweb.cse.ohio-state.edu/...sw2/...Implementations-I.pdfKernel Implementations I. 15 January 2019 OSU CSE 1. So, What’s Inside](https://reader033.vdocuments.site/reader033/viewer/2022060508/5f2390410b6c376f085521c6/html5/thumbnails/13.jpg)
A Tower of Abstractions
• Bowling pins• Vectors• Numbers• Bits• Voltages• Electrons• ???
15 January 2019 OSU CSE 13
Voltages may be built on top of (?) electrons…
![Page 14: Kernel Implementations I - Computer Science and Engineeringweb.cse.ohio-state.edu/...sw2/...Implementations-I.pdfKernel Implementations I. 15 January 2019 OSU CSE 1. So, What’s Inside](https://reader033.vdocuments.site/reader033/viewer/2022060508/5f2390410b6c376f085521c6/html5/thumbnails/14.jpg)
Interpretation of Representation
• Let’s not take the tower-building metaphor too far!
• A better approach is to think about interpreting a lower-level configuration (a.k.a. a representation) to get a higher-level value
15 January 2019 OSU CSE 14
![Page 15: Kernel Implementations I - Computer Science and Engineeringweb.cse.ohio-state.edu/...sw2/...Implementations-I.pdfKernel Implementations I. 15 January 2019 OSU CSE 1. So, What’s Inside](https://reader033.vdocuments.site/reader033/viewer/2022060508/5f2390410b6c376f085521c6/html5/thumbnails/15.jpg)
A Tower of Abstractions
• Bowling pins• Vectors• Numbers• Bits• Voltages• Electrons• ???
15 January 2019 OSU CSE 15
(Configurations of)bits may be interpreted
as numbers...
![Page 16: Kernel Implementations I - Computer Science and Engineeringweb.cse.ohio-state.edu/...sw2/...Implementations-I.pdfKernel Implementations I. 15 January 2019 OSU CSE 1. So, What’s Inside](https://reader033.vdocuments.site/reader033/viewer/2022060508/5f2390410b6c376f085521c6/html5/thumbnails/16.jpg)
A Tower of Abstractions
• Bowling pins• Vectors• Numbers• Bits• Voltages• Electrons• ???
15 January 2019 OSU CSE 16
(Configurations of) voltages may be
interpreted as bits…
![Page 17: Kernel Implementations I - Computer Science and Engineeringweb.cse.ohio-state.edu/...sw2/...Implementations-I.pdfKernel Implementations I. 15 January 2019 OSU CSE 1. So, What’s Inside](https://reader033.vdocuments.site/reader033/viewer/2022060508/5f2390410b6c376f085521c6/html5/thumbnails/17.jpg)
A Tower of Abstractions
• Bowling pins• Vectors• Numbers• Bits• Voltages• Electrons• ???
15 January 2019 OSU CSE 17
(Configurations of) electrons may be
interpreted as voltages…
![Page 18: Kernel Implementations I - Computer Science and Engineeringweb.cse.ohio-state.edu/...sw2/...Implementations-I.pdfKernel Implementations I. 15 January 2019 OSU CSE 1. So, What’s Inside](https://reader033.vdocuments.site/reader033/viewer/2022060508/5f2390410b6c376f085521c6/html5/thumbnails/18.jpg)
First Example: QueueKernel
• For QueueKernel, one idea is to represent a Queue variable’s value by using a java.util.List variable
• By convention (of the OSU CSE components), a kernel class that directly represents the new type using a component from the Java libraries that is very similar, has a name ending in “L”– In this case, it is called Queue1L
15 January 2019 OSU CSE 18
![Page 19: Kernel Implementations I - Computer Science and Engineeringweb.cse.ohio-state.edu/...sw2/...Implementations-I.pdfKernel Implementations I. 15 January 2019 OSU CSE 1. So, What’s Inside](https://reader033.vdocuments.site/reader033/viewer/2022060508/5f2390410b6c376f085521c6/html5/thumbnails/19.jpg)
Detailed Example: Queue1L
• What existing components (including built-in types of Java, and the Java libraries) could you build it on top of?– In other words, what could you use as a data
representation that could be interpreted as a Queue value?
15 January 2019 OSU CSE 19
![Page 20: Kernel Implementations I - Computer Science and Engineeringweb.cse.ohio-state.edu/...sw2/...Implementations-I.pdfKernel Implementations I. 15 January 2019 OSU CSE 1. So, What’s Inside](https://reader033.vdocuments.site/reader033/viewer/2022060508/5f2390410b6c376f085521c6/html5/thumbnails/20.jpg)
Context of Queue1L
15 January 2019 OSU CSE 20
Queue
Queue1L
implements
QueueKernel
extends
QueueSecondary
extends
Object
extends
Standard
extends
Has bodies for the constructor, plus the 7
methods from Standardand QueueKernel.
Iterable
extends
![Page 21: Kernel Implementations I - Computer Science and Engineeringweb.cse.ohio-state.edu/...sw2/...Implementations-I.pdfKernel Implementations I. 15 January 2019 OSU CSE 1. So, What’s Inside](https://reader033.vdocuments.site/reader033/viewer/2022060508/5f2390410b6c376f085521c6/html5/thumbnails/21.jpg)
Context of Queue1L
15 January 2019 OSU CSE 21
Queue
Queue1L
implements
QueueKernel
extends
QueueSecondary
extends
Object
extends
Standard
extends
Iterable
extends
newInstanceclear
transferFrom
constructorenqueuedequeuelengthiterator
![Page 22: Kernel Implementations I - Computer Science and Engineeringweb.cse.ohio-state.edu/...sw2/...Implementations-I.pdfKernel Implementations I. 15 January 2019 OSU CSE 1. So, What’s Inside](https://reader033.vdocuments.site/reader033/viewer/2022060508/5f2390410b6c376f085521c6/html5/thumbnails/22.jpg)
Instance Variables
• Each separate Queue1L object has its own distinct java.util.List variable that represents its object value
• Note: In the code we will examine for Queue1L, there is a declaration of a private instance variable whose value is the java.util.List that represents one Queue1L object (namely, this)
15 January 2019 OSU CSE 22
![Page 23: Kernel Implementations I - Computer Science and Engineeringweb.cse.ohio-state.edu/...sw2/...Implementations-I.pdfKernel Implementations I. 15 January 2019 OSU CSE 1. So, What’s Inside](https://reader033.vdocuments.site/reader033/viewer/2022060508/5f2390410b6c376f085521c6/html5/thumbnails/23.jpg)
Instance Variables
• Each separate Queue1L object has its own distinct java.util.List variable that represents its object value
• Note: In the code we will examine for Queue1L, there is a declaration of a private instance variable whose value is the java.util.List that represents one Queue1L object (namely, this)
15 January 2019 OSU CSE 23
The adjective instance means there is a distinct variable (with the same name) for each instance (i.e., each distinct object) of the class in
which it is declared.
![Page 24: Kernel Implementations I - Computer Science and Engineeringweb.cse.ohio-state.edu/...sw2/...Implementations-I.pdfKernel Implementations I. 15 January 2019 OSU CSE 1. So, What’s Inside](https://reader033.vdocuments.site/reader033/viewer/2022060508/5f2390410b6c376f085521c6/html5/thumbnails/24.jpg)
Let’s Look at Queue1L.java
15 January 2019 OSU CSE 24
![Page 25: Kernel Implementations I - Computer Science and Engineeringweb.cse.ohio-state.edu/...sw2/...Implementations-I.pdfKernel Implementations I. 15 January 2019 OSU CSE 1. So, What’s Inside](https://reader033.vdocuments.site/reader033/viewer/2022060508/5f2390410b6c376f085521c6/html5/thumbnails/25.jpg)
Other Representations?
• Is there any other way to use a java.util.List to represent an object value of type Queue?
15 January 2019 OSU CSE 25
![Page 26: Kernel Implementations I - Computer Science and Engineeringweb.cse.ohio-state.edu/...sw2/...Implementations-I.pdfKernel Implementations I. 15 January 2019 OSU CSE 1. So, What’s Inside](https://reader033.vdocuments.site/reader033/viewer/2022060508/5f2390410b6c376f085521c6/html5/thumbnails/26.jpg)
Other Representations?
• Is there any other way to use a java.util.List to represent an object value of type Queue?
• Yes!– What if you simply thought of the front of the Queue as being at the right end of the java.util.List rather than the left?
– How would the code change with this “reversed” interpretation?
15 January 2019 OSU CSE 26
![Page 27: Kernel Implementations I - Computer Science and Engineeringweb.cse.ohio-state.edu/...sw2/...Implementations-I.pdfKernel Implementations I. 15 January 2019 OSU CSE 1. So, What’s Inside](https://reader033.vdocuments.site/reader033/viewer/2022060508/5f2390410b6c376f085521c6/html5/thumbnails/27.jpg)
Resources
• OSU CSE Components API: Queue– http://cse.osu.edu/software/common/doc/
15 January 2019 OSU CSE 27