Posts

Showing posts from February, 2017

Kotlin Language Features Related to Null Handling

Any software engineer with a Java background would find the null handling features in the Kotlin language interesting. Let's summarize this topic with some examples. Nullable types: In Kotlin, types are non-nullable by default. If you want a variable to be able to hold a null value, you need to explicitly declare its type as nullable using the Type? syntax. For example, String? denotes a nullable string, while String represents a non-nullable string. Safe calls (?.): Kotlin introduces the safe call operator (?.) for handling nullable types. It allows you to safely invoke a method or access a property on a nullable object. If the object is null, the expression returns null instead of throwing a NullPointerException. Example: data class Person(val name: String, val age: Int, val address: String?) fun main() {     // Create a person with a nullable address     val person1 = Person("John Doe", 25, "123 Main Street")     val person2 = Person("Jane Doe", 30,

Understanding SimpleScalar codebase

Among others, sim-safe is the most user-friendly simulator and the implementation is crafted for clarity. Generally there are two types of simulators: Functional simulators implement architecture (what programmers see) perform the actual execution sim-fast, sim-safe , sim-profile, sim-cache Performance simulators implement micro-architecture model system internals measure time sim-outorder Question: What is Dlite debugger? How can we debug a simulator?? DLite is a symbolic debugger. To use it, start the simulator with -i option Then user the debugger commands, for example: "step" Question: To work with TLB, do I have to fully understand sim-outorder ?? http://www.simplescalar.com/docs/simple_tutorial_v2.pdf page:14 http://www.simplescalar.com/docs/hack_guide_v2.pdf Question: How does sim-safe count number of instructions? Where is iTLB related code? In main.c file: /* options database*/ struct opt_odb_t *sim_odb; /* simulated re

More on Virtual Memory and TLB

Below is a series of videos on virtual memory: https://www.youtube.com/watch?v=KNUJhZCQZ9c Virtual memory is a layer of indirection. Without virtual memory the program address would be equal to the RAM address.  Discs are 1000x slower than RAM. What happens if a page is not on RAM?  Page table tells that the page is on disc. Hardware (CPU) generates a page fault exception . This exception will be picked up by the operating system. ( page fault handler ) Operating system kicks out (evicts) another page from RAM and writes it to disc If the page is dirty, it needs to be written back to disc first. Then OS reads the page from disk and puts it in RAM Then OS updates the page table to map the new page Finally OS jumps back to the instruction that caused the page fault A page fault is the slowest possible thing that can happen to a computer. (except for human interaction) Some operating sytems do not use paging: iOS kills the program if it uses too much memory. TLB sh

Popular posts from this blog

Trie Data Structure and Finding Patterns in a Collection of Words

swapLexOrder: Finding lexicographically largest string

A Graph Application in Java: Using WordNet to Find Outcast Words