SlideShare a Scribd company logo
1 of 20
The 38th
International convention MIPRO 2015
Computers in Technical Systems
Tiny Operating System Kernel for
Education Purposes
Samir Ribić, Adnan Salihbegović
Faculty of Electrical Engineering, Sarajevo
May 25-29, 2015 Opatija, Croatia
Computers in Education
• 3 basic styles of Operating systems courses
• User-oriented courses, inclining towards the practical
problems like installation, configuration and
administration of the operating systems (IT, IS).
• Theoretical analysis of algorithms that arise in the
implementation of operating systems is an approach
that is dominant in operating systems courses at the
universities oriented towards computer science (CS, SE).
• Explanation and source code development of an
operating system kernel offers better understanding of
OS fundamentals, but leaves less room for teaching
alternative approaches and examples (CS, CE).
Introduction
May 28, 2015 Ribić-Salihbegović/ETF Sarajevo 2
• Size matters! One megabyte=500 pages=full semester
• Code centric course or code as illustration?
• No full blown OS:

Linux 3.10 has 17 million lines of code,

Windows Research Kernel 83000 lines of code

Unix like kernels used in education:

Minix (16000 lines, complete), Xinu (8000, no file
system), Nachos (5000, OO virtual machine)

Old Unix versions

Linux 0.11 (14000), Qutenix (5500), XV6 (8300)

Not Unix like

GeekOS (3000, no FS), Black (CP/M like, 1200)
RELATED COURSES
May 28, 2015 Ribić-Salihbegović/ETF Sarajevo 3
• Standalone kernel capable to run under real hardware
(PC) and emulator
• 386-compatible PCs in 32 bit mode, with peripherals
that include an IDE drive, keyboard and text display.
• C language, when necessary assembly
• It was necessary to include in the kernel the range of
functionalities like: inputs/outputs, the organization of
memory, disk, file system and scheduling processes.
• Simplest algorithms in the realization of subsystems
• Layered architecture to follow the lessons: LEKOS
(Layered Educational Kernel of Operating System).
DESIGN GOALS
May 28, 2015 Ribić-Salihbegović/ETF Sarajevo 4
SOURCE FILES
May 28, 2015 Ribić-Salihbegović/ETF Sarajevo 5
• Written in assembly language Max. size of 512 bytes
and finished with the signature. It consists of two main
parts, 16 bit and 32 bit.
• 16bit: executed at 000: 7c00 calling two times BIOS
interrupt 13h. The first call resets disk controller, the
second call transfers some sectors from the disk into the
RAM. With this transfer, the file with kernel is loaded
with into the memory. Segment GDTR register is loaded
to point to a table that simply maps the memory
segments for linear addressing.
• 32 bit: Program switches to protected mode, sets the
segment registers, stack pointer and jumps into the
kernel.
BOOT SECTOR
May 28, 2015 Ribić-Salihbegović/ETF Sarajevo 6
• The operating system is running on an empty machine.
Since the programmer has no standard C library at
disposal, several necessary functions for operation with
strings have to be provided. These functions can be
implemented purely in C language. The realized
functions are: strncmp, strncpy and itoa.
STRINGS
May 28, 2015 Ribić-Salihbegović/ETF Sarajevo 7
• The standard C language does not have built-in access
to I/O mapped peripherals. Therefore, it is necessary to
use assembler routines, but they are easily
encapsulated in the appropriate subroutines using inline
assembler built into the GCC.
unsigned char in(unsigned short _port){
unsigned char result;
__asm__("in %%dx,%%al": "=a" (result):"d" (_port));
return result;
}
I/O PORTS
May 28, 2015 Ribić-Salihbegović/ETF Sarajevo 8
• Textmode video buffer on PCs is located on the
absolute address 0xB8000. Access to the textmode
memory is in the form of a matrix with 80 columns, in
format of ASCII characters for every character on the
screen.
void Print(const char * msg) {
unsigned long i;
unsigned char *vmem;
vmem= (unsigned char *)0xB8000;
vmem += cursorpos<<1; i = 0;
while (msg[i] != 0) {
*vmem = msg[i++]; vmem += 2;
}
cursorpos += i;
hardwarecursor();
}
VIDEO
May 28, 2015 Ribić-Salihbegović/ETF Sarajevo 9
• The relatively easy part of this driver works directly
with scan codes. When the key is pressed (0x64h port
returns on zero bit the value of 1), the value of the
pressed key can be read from port 0x60h.
unsigned char GetScanCode(){
static char code;
if(in(0x64) & (0x01)) code = in(0x60);
else code = 0;
return code;
}
• Larger part of this driver is a subroutine that converts
the scanned code in ASCII, in cases with SHIFT, CTRL
combination and direct keypress.
KEYBOARD
May 28, 2015 Ribić-Salihbegović/ETF Sarajevo 10
• The next task in kernel development was to avoid busy
wait. For this purpose the interrupts are used. In
protected mode IDTR register points to the interrupt
vector table.
• The first of these is related to keyboard keypress
reading. Received scan code of the pressed key is placed
in a circular buffer.
• Second implemented interrupt is the timer interrupt. Its
task is simple, increases the counter by one every 10ms.
void Clock() {
__asm__ __volatile__("pushal"); elapsedtime++; out(0x20,0x20);
__asm__ __volatile__ (" popal ; leave ; iret");
}
INTERRUPTS
May 28, 2015 Ribić-Salihbegović/ETF Sarajevo 11
• IDE hard drive is used, because it is the simplest kind of
disk access at a low level. The ports 0x1f1 to 0x1f7 are
used to send LBA or CHS address of the first sector in a
group that user wants to transfer to RAM memory, with
the information how much sectors wants to transfer.
DISK DRIVER
May 28, 2015 Ribić-Salihbegović/ETF Sarajevo 12
• The largest subsystem, but still simple enough.
Therefore, the directory was implemented with only
one level (redy to be expanded), with a continuous
allocation of files on disk.
• Opening of the file copies directory element with
forwarded location number in the directory table, to the
free location in the table of open files
• Writing to a file: finding blocks on the disk, and then
the first of them is loaded into the buffer. Data is
transferred from the user buffer in the buffer disk block.
At the end of the buffer, the block is written to the disc.
Care that recorded blocks do not exceed the limit of file.
FILE SYSTEM
May 28, 2015 Ribić-Salihbegović/ETF Sarajevo 13
• int SaveDirEntry(unsigned int num)
• int OpenFileByNumber(int num)
• int OpenFile(char * name)
• int DeleteFile(char * name)
• int CreateFile(char * name, unsigned int maxsize)
• int CloseFile(int fd)
• int SeekFile(int fd, char * buffer,unsigned int position)
• int ReadFile(int fd, char * buffer,unsigned int size)
• int WriteFile(int fd, char * buffer,unsigned int size)
• int FormatPartition(int startsector, int maxfiles, int
partitionsize )
FILE SYSTEM
May 28, 2015 Ribić-Salihbegović/ETF Sarajevo 14
• In the operating system, memory between 0 and 640 KB
is reserved for kernel and its tables, while the custom
applications are allocated memory space above 1 MB.
• The memory management module is implemented with
two strategies, one for the physical memory and one for
virtual memory.
• The physical memory block is represented by
memTable element. First fit strategy
• Virtual memory uses 386 paging by mapping 4M logical
space to discontinual physical space
MEMORY MANAGER
May 28, 2015 Ribić-Salihbegović/ETF Sarajevo 15
• Cooperative multitasking
• setjmp macro makes context switch
• schedule() routine calls Round Robin
void schedule(void) {
unsigned prev;
static int cr0;
prev = current;
do {
current++; // round-robin switch to next task
if(current >= NUM_TASKS)
current = 0;
} while (g_tasks[current].state!=READY);
idlecpu=(prev==current==0);
if(setjmp(g_tasks[prev].regcontext) != 0)
return;
ActivatePaging ( g_tasks[current].pagetable);
longjmp(g_tasks[current].regcontext, 1);
}
PROCESS MANAGEMENT
May 28, 2015 Ribić-Salihbegović/ETF Sarajevo 16
Remember
Switch
• Since the scheduler is of the cooperative type, the
system calls are, beside the basic function, extended
with the call to scheduler, as in the following example:
int _OpenFile(char * name) {
int i=OpenFile(name);
schedule();
return i;
}
SYSTEM CALLS
May 28, 2015 Ribić-Salihbegović/ETF Sarajevo 17
• After several explained layers, main program started
with different test
TESTS
May 28, 2015 Ribić-Salihbegović/ETF Sarajevo 18
• 2 possible approaches:
•Change order of the course and introduce concepts
together with layers
•Classic order, and example in the last week
• Now used as example instead previously used oln linux
or Minix
• Much greater level of understanding
• 90 minutes enough to explain the whole source code
• Contribution to demistify Operating systems
CHANGES IN EDUCATION PROCESS
May 28, 2015 Ribić-Salihbegović/ETF Sarajevo 19
• Minimalist operating systems do not strive to be used in
real world applications, but can be of great importance
as an educational tool to display the principles of
operating systems structure and organization.
• Making use of the simplest algorithms, the developed
operating system kernel has fulfilled its objective and
purpose, to illustrate the practical side of the operating
systems role and inner working, while not spending too
much time on its explanation, at the expense of
theoretical considerations and approaches.
Conclusion
May 28, 2015 Ribić-Salihbegović/ETF Sarajevo 20

More Related Content

What's hot

05 instruction set design and architecture
05 instruction set design and architecture05 instruction set design and architecture
05 instruction set design and architectureWaqar Jamil
 
Design of Synthesizable Asynchronous FIFO And Implementation on FPGA
Design of Synthesizable Asynchronous FIFO And Implementation on FPGADesign of Synthesizable Asynchronous FIFO And Implementation on FPGA
Design of Synthesizable Asynchronous FIFO And Implementation on FPGAIJERDJOURNAL
 
Computer organization and architecture
Computer organization and architectureComputer organization and architecture
Computer organization and architectureSubesh Kumar Yadav
 
Register transfer &amp; microoperations moris mano ch 04
Register transfer &amp; microoperations    moris mano ch 04Register transfer &amp; microoperations    moris mano ch 04
Register transfer &amp; microoperations moris mano ch 04thearticlenow
 
Introduction to Computer Architecture and Organization
Introduction to Computer Architecture and OrganizationIntroduction to Computer Architecture and Organization
Introduction to Computer Architecture and OrganizationDr. Balaji Ganesh Rajagopal
 
W8_1: Intro to UoS Educational Processor
W8_1: Intro to UoS Educational ProcessorW8_1: Intro to UoS Educational Processor
W8_1: Intro to UoS Educational ProcessorDaniel Roggen
 
10 instruction sets characteristics
10 instruction sets characteristics10 instruction sets characteristics
10 instruction sets characteristicsdilip kumar
 
SIMD Processing Using Compiler Intrinsics
SIMD Processing Using Compiler IntrinsicsSIMD Processing Using Compiler Intrinsics
SIMD Processing Using Compiler IntrinsicsRichard Thomson
 
Program execution, straight line sequence and branching
Program execution, straight line sequence and branchingProgram execution, straight line sequence and branching
Program execution, straight line sequence and branchingJyotiprakashMishra18
 
CNIT 127 Lecture 7: Intro to 64-Bit Assembler (not in book)
CNIT 127 Lecture 7: Intro to 64-Bit Assembler (not in book)CNIT 127 Lecture 7: Intro to 64-Bit Assembler (not in book)
CNIT 127 Lecture 7: Intro to 64-Bit Assembler (not in book)Sam Bowne
 
10 Instruction Sets Characteristics
10  Instruction  Sets Characteristics10  Instruction  Sets Characteristics
10 Instruction Sets CharacteristicsJeanie Delos Arcos
 
PARALLELISM IN MULTICORE PROCESSORS
PARALLELISM  IN MULTICORE PROCESSORSPARALLELISM  IN MULTICORE PROCESSORS
PARALLELISM IN MULTICORE PROCESSORSAmirthavalli Senthil
 
Computer organization basics
Computer organization  basicsComputer organization  basics
Computer organization basicsDeepak John
 

What's hot (19)

05 instruction set design and architecture
05 instruction set design and architecture05 instruction set design and architecture
05 instruction set design and architecture
 
Design of Synthesizable Asynchronous FIFO And Implementation on FPGA
Design of Synthesizable Asynchronous FIFO And Implementation on FPGADesign of Synthesizable Asynchronous FIFO And Implementation on FPGA
Design of Synthesizable Asynchronous FIFO And Implementation on FPGA
 
Computer organization and architecture
Computer organization and architectureComputer organization and architecture
Computer organization and architecture
 
MIPS Architecture
MIPS ArchitectureMIPS Architecture
MIPS Architecture
 
EE270_Final_Project
EE270_Final_ProjectEE270_Final_Project
EE270_Final_Project
 
Register transfer &amp; microoperations moris mano ch 04
Register transfer &amp; microoperations    moris mano ch 04Register transfer &amp; microoperations    moris mano ch 04
Register transfer &amp; microoperations moris mano ch 04
 
Introduction to Computer Architecture and Organization
Introduction to Computer Architecture and OrganizationIntroduction to Computer Architecture and Organization
Introduction to Computer Architecture and Organization
 
W8_1: Intro to UoS Educational Processor
W8_1: Intro to UoS Educational ProcessorW8_1: Intro to UoS Educational Processor
W8_1: Intro to UoS Educational Processor
 
10 instruction sets characteristics
10 instruction sets characteristics10 instruction sets characteristics
10 instruction sets characteristics
 
Registers
RegistersRegisters
Registers
 
SIMD Processing Using Compiler Intrinsics
SIMD Processing Using Compiler IntrinsicsSIMD Processing Using Compiler Intrinsics
SIMD Processing Using Compiler Intrinsics
 
Program execution, straight line sequence and branching
Program execution, straight line sequence and branchingProgram execution, straight line sequence and branching
Program execution, straight line sequence and branching
 
CNIT 127 Lecture 7: Intro to 64-Bit Assembler (not in book)
CNIT 127 Lecture 7: Intro to 64-Bit Assembler (not in book)CNIT 127 Lecture 7: Intro to 64-Bit Assembler (not in book)
CNIT 127 Lecture 7: Intro to 64-Bit Assembler (not in book)
 
10 Instruction Sets Characteristics
10  Instruction  Sets Characteristics10  Instruction  Sets Characteristics
10 Instruction Sets Characteristics
 
PARALLELISM IN MULTICORE PROCESSORS
PARALLELISM  IN MULTICORE PROCESSORSPARALLELISM  IN MULTICORE PROCESSORS
PARALLELISM IN MULTICORE PROCESSORS
 
MEMORY & I/O SYSTEMS
MEMORY & I/O SYSTEMS                          MEMORY & I/O SYSTEMS
MEMORY & I/O SYSTEMS
 
Computer organization basics
Computer organization  basicsComputer organization  basics
Computer organization basics
 
Computer Abstractions and Technology
Computer Abstractions and TechnologyComputer Abstractions and Technology
Computer Abstractions and Technology
 
Sap 1
Sap 1Sap 1
Sap 1
 

Similar to Mini kernel

Simplified instructional computer
Simplified instructional computerSimplified instructional computer
Simplified instructional computerKirby Fabro
 
Week1 Electronic System-level ESL Design and SystemC Begin
Week1 Electronic System-level ESL Design and SystemC BeginWeek1 Electronic System-level ESL Design and SystemC Begin
Week1 Electronic System-level ESL Design and SystemC Begin敬倫 林
 
Microchip's PIC Micro Controller
Microchip's PIC Micro ControllerMicrochip's PIC Micro Controller
Microchip's PIC Micro ControllerMidhu S V Unnithan
 
Labview1_ Computer Applications in Control_ACRRL
Labview1_ Computer Applications in Control_ACRRLLabview1_ Computer Applications in Control_ACRRL
Labview1_ Computer Applications in Control_ACRRLMohammad Sabouri
 
RISC Vs CISC, Harvard v/s Van Neumann
RISC Vs CISC, Harvard v/s Van NeumannRISC Vs CISC, Harvard v/s Van Neumann
RISC Vs CISC, Harvard v/s Van NeumannRavikumar Tiwari
 
Pre requisite of COA- for Micro controller Embedded systems
Pre requisite of COA- for Micro controller Embedded systemsPre requisite of COA- for Micro controller Embedded systems
Pre requisite of COA- for Micro controller Embedded systemsSMITA V MORE
 
Chapter 1SyllabusCatalog Description Computer structu
Chapter 1SyllabusCatalog Description Computer structuChapter 1SyllabusCatalog Description Computer structu
Chapter 1SyllabusCatalog Description Computer structuEstelaJeffery653
 
How to deploy & optimize eZ Publish
How to deploy & optimize eZ PublishHow to deploy & optimize eZ Publish
How to deploy & optimize eZ PublishKaliop-slide
 
Toward Hybrid Cloud Serverless Transparency with Lithops Framework
Toward Hybrid Cloud Serverless Transparency with Lithops FrameworkToward Hybrid Cloud Serverless Transparency with Lithops Framework
Toward Hybrid Cloud Serverless Transparency with Lithops FrameworkLibbySchulze
 
Assembly chapter One.pptx
Assembly chapter One.pptxAssembly chapter One.pptx
Assembly chapter One.pptxssuserb78e291
 
Beyond Breakpoints: A Tour of Dynamic Analysis
Beyond Breakpoints: A Tour of Dynamic AnalysisBeyond Breakpoints: A Tour of Dynamic Analysis
Beyond Breakpoints: A Tour of Dynamic AnalysisC4Media
 
(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
 
Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015
Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015
Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015Windows Developer
 
8 bit Microprocessor with Single Vectored Interrupt
8 bit Microprocessor with Single Vectored Interrupt8 bit Microprocessor with Single Vectored Interrupt
8 bit Microprocessor with Single Vectored InterruptHardik Manocha
 
Layers of Computer Science, ISA and uArch Alexander Titov 20 September 2014.
Layers of Computer Science, ISA and uArch Alexander Titov 20 September 2014.Layers of Computer Science, ISA and uArch Alexander Titov 20 September 2014.
Layers of Computer Science, ISA and uArch Alexander Titov 20 September 2014.li50916ku
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAAiman Hud
 

Similar to Mini kernel (20)

Kirby, Fabro
Kirby, FabroKirby, Fabro
Kirby, Fabro
 
Simplified instructional computer
Simplified instructional computerSimplified instructional computer
Simplified instructional computer
 
Week1 Electronic System-level ESL Design and SystemC Begin
Week1 Electronic System-level ESL Design and SystemC BeginWeek1 Electronic System-level ESL Design and SystemC Begin
Week1 Electronic System-level ESL Design and SystemC Begin
 
Microchip's PIC Micro Controller
Microchip's PIC Micro ControllerMicrochip's PIC Micro Controller
Microchip's PIC Micro Controller
 
Labview1_ Computer Applications in Control_ACRRL
Labview1_ Computer Applications in Control_ACRRLLabview1_ Computer Applications in Control_ACRRL
Labview1_ Computer Applications in Control_ACRRL
 
RISC Vs CISC, Harvard v/s Van Neumann
RISC Vs CISC, Harvard v/s Van NeumannRISC Vs CISC, Harvard v/s Van Neumann
RISC Vs CISC, Harvard v/s Van Neumann
 
Module_01.ppt
Module_01.pptModule_01.ppt
Module_01.ppt
 
Pre requisite of COA- for Micro controller Embedded systems
Pre requisite of COA- for Micro controller Embedded systemsPre requisite of COA- for Micro controller Embedded systems
Pre requisite of COA- for Micro controller Embedded systems
 
embedded C.pptx
embedded C.pptxembedded C.pptx
embedded C.pptx
 
Introduction to Blackfin BF532 DSP
Introduction to Blackfin BF532 DSPIntroduction to Blackfin BF532 DSP
Introduction to Blackfin BF532 DSP
 
Chapter 1SyllabusCatalog Description Computer structu
Chapter 1SyllabusCatalog Description Computer structuChapter 1SyllabusCatalog Description Computer structu
Chapter 1SyllabusCatalog Description Computer structu
 
How to deploy & optimize eZ Publish
How to deploy & optimize eZ PublishHow to deploy & optimize eZ Publish
How to deploy & optimize eZ Publish
 
Toward Hybrid Cloud Serverless Transparency with Lithops Framework
Toward Hybrid Cloud Serverless Transparency with Lithops FrameworkToward Hybrid Cloud Serverless Transparency with Lithops Framework
Toward Hybrid Cloud Serverless Transparency with Lithops Framework
 
Assembly chapter One.pptx
Assembly chapter One.pptxAssembly chapter One.pptx
Assembly chapter One.pptx
 
Beyond Breakpoints: A Tour of Dynamic Analysis
Beyond Breakpoints: A Tour of Dynamic AnalysisBeyond Breakpoints: A Tour of Dynamic Analysis
Beyond Breakpoints: A Tour of Dynamic Analysis
 
(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
 
Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015
Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015
Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015
 
8 bit Microprocessor with Single Vectored Interrupt
8 bit Microprocessor with Single Vectored Interrupt8 bit Microprocessor with Single Vectored Interrupt
8 bit Microprocessor with Single Vectored Interrupt
 
Layers of Computer Science, ISA and uArch Alexander Titov 20 September 2014.
Layers of Computer Science, ISA and uArch Alexander Titov 20 September 2014.Layers of Computer Science, ISA and uArch Alexander Titov 20 September 2014.
Layers of Computer Science, ISA and uArch Alexander Titov 20 September 2014.
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 

Recently uploaded

“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 

Recently uploaded (20)

“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 

Mini kernel

  • 1. The 38th International convention MIPRO 2015 Computers in Technical Systems Tiny Operating System Kernel for Education Purposes Samir Ribić, Adnan Salihbegović Faculty of Electrical Engineering, Sarajevo May 25-29, 2015 Opatija, Croatia Computers in Education
  • 2. • 3 basic styles of Operating systems courses • User-oriented courses, inclining towards the practical problems like installation, configuration and administration of the operating systems (IT, IS). • Theoretical analysis of algorithms that arise in the implementation of operating systems is an approach that is dominant in operating systems courses at the universities oriented towards computer science (CS, SE). • Explanation and source code development of an operating system kernel offers better understanding of OS fundamentals, but leaves less room for teaching alternative approaches and examples (CS, CE). Introduction May 28, 2015 Ribić-Salihbegović/ETF Sarajevo 2
  • 3. • Size matters! One megabyte=500 pages=full semester • Code centric course or code as illustration? • No full blown OS:  Linux 3.10 has 17 million lines of code,  Windows Research Kernel 83000 lines of code  Unix like kernels used in education:  Minix (16000 lines, complete), Xinu (8000, no file system), Nachos (5000, OO virtual machine)  Old Unix versions  Linux 0.11 (14000), Qutenix (5500), XV6 (8300)  Not Unix like  GeekOS (3000, no FS), Black (CP/M like, 1200) RELATED COURSES May 28, 2015 Ribić-Salihbegović/ETF Sarajevo 3
  • 4. • Standalone kernel capable to run under real hardware (PC) and emulator • 386-compatible PCs in 32 bit mode, with peripherals that include an IDE drive, keyboard and text display. • C language, when necessary assembly • It was necessary to include in the kernel the range of functionalities like: inputs/outputs, the organization of memory, disk, file system and scheduling processes. • Simplest algorithms in the realization of subsystems • Layered architecture to follow the lessons: LEKOS (Layered Educational Kernel of Operating System). DESIGN GOALS May 28, 2015 Ribić-Salihbegović/ETF Sarajevo 4
  • 5. SOURCE FILES May 28, 2015 Ribić-Salihbegović/ETF Sarajevo 5
  • 6. • Written in assembly language Max. size of 512 bytes and finished with the signature. It consists of two main parts, 16 bit and 32 bit. • 16bit: executed at 000: 7c00 calling two times BIOS interrupt 13h. The first call resets disk controller, the second call transfers some sectors from the disk into the RAM. With this transfer, the file with kernel is loaded with into the memory. Segment GDTR register is loaded to point to a table that simply maps the memory segments for linear addressing. • 32 bit: Program switches to protected mode, sets the segment registers, stack pointer and jumps into the kernel. BOOT SECTOR May 28, 2015 Ribić-Salihbegović/ETF Sarajevo 6
  • 7. • The operating system is running on an empty machine. Since the programmer has no standard C library at disposal, several necessary functions for operation with strings have to be provided. These functions can be implemented purely in C language. The realized functions are: strncmp, strncpy and itoa. STRINGS May 28, 2015 Ribić-Salihbegović/ETF Sarajevo 7
  • 8. • The standard C language does not have built-in access to I/O mapped peripherals. Therefore, it is necessary to use assembler routines, but they are easily encapsulated in the appropriate subroutines using inline assembler built into the GCC. unsigned char in(unsigned short _port){ unsigned char result; __asm__("in %%dx,%%al": "=a" (result):"d" (_port)); return result; } I/O PORTS May 28, 2015 Ribić-Salihbegović/ETF Sarajevo 8
  • 9. • Textmode video buffer on PCs is located on the absolute address 0xB8000. Access to the textmode memory is in the form of a matrix with 80 columns, in format of ASCII characters for every character on the screen. void Print(const char * msg) { unsigned long i; unsigned char *vmem; vmem= (unsigned char *)0xB8000; vmem += cursorpos<<1; i = 0; while (msg[i] != 0) { *vmem = msg[i++]; vmem += 2; } cursorpos += i; hardwarecursor(); } VIDEO May 28, 2015 Ribić-Salihbegović/ETF Sarajevo 9
  • 10. • The relatively easy part of this driver works directly with scan codes. When the key is pressed (0x64h port returns on zero bit the value of 1), the value of the pressed key can be read from port 0x60h. unsigned char GetScanCode(){ static char code; if(in(0x64) & (0x01)) code = in(0x60); else code = 0; return code; } • Larger part of this driver is a subroutine that converts the scanned code in ASCII, in cases with SHIFT, CTRL combination and direct keypress. KEYBOARD May 28, 2015 Ribić-Salihbegović/ETF Sarajevo 10
  • 11. • The next task in kernel development was to avoid busy wait. For this purpose the interrupts are used. In protected mode IDTR register points to the interrupt vector table. • The first of these is related to keyboard keypress reading. Received scan code of the pressed key is placed in a circular buffer. • Second implemented interrupt is the timer interrupt. Its task is simple, increases the counter by one every 10ms. void Clock() { __asm__ __volatile__("pushal"); elapsedtime++; out(0x20,0x20); __asm__ __volatile__ (" popal ; leave ; iret"); } INTERRUPTS May 28, 2015 Ribić-Salihbegović/ETF Sarajevo 11
  • 12. • IDE hard drive is used, because it is the simplest kind of disk access at a low level. The ports 0x1f1 to 0x1f7 are used to send LBA or CHS address of the first sector in a group that user wants to transfer to RAM memory, with the information how much sectors wants to transfer. DISK DRIVER May 28, 2015 Ribić-Salihbegović/ETF Sarajevo 12
  • 13. • The largest subsystem, but still simple enough. Therefore, the directory was implemented with only one level (redy to be expanded), with a continuous allocation of files on disk. • Opening of the file copies directory element with forwarded location number in the directory table, to the free location in the table of open files • Writing to a file: finding blocks on the disk, and then the first of them is loaded into the buffer. Data is transferred from the user buffer in the buffer disk block. At the end of the buffer, the block is written to the disc. Care that recorded blocks do not exceed the limit of file. FILE SYSTEM May 28, 2015 Ribić-Salihbegović/ETF Sarajevo 13
  • 14. • int SaveDirEntry(unsigned int num) • int OpenFileByNumber(int num) • int OpenFile(char * name) • int DeleteFile(char * name) • int CreateFile(char * name, unsigned int maxsize) • int CloseFile(int fd) • int SeekFile(int fd, char * buffer,unsigned int position) • int ReadFile(int fd, char * buffer,unsigned int size) • int WriteFile(int fd, char * buffer,unsigned int size) • int FormatPartition(int startsector, int maxfiles, int partitionsize ) FILE SYSTEM May 28, 2015 Ribić-Salihbegović/ETF Sarajevo 14
  • 15. • In the operating system, memory between 0 and 640 KB is reserved for kernel and its tables, while the custom applications are allocated memory space above 1 MB. • The memory management module is implemented with two strategies, one for the physical memory and one for virtual memory. • The physical memory block is represented by memTable element. First fit strategy • Virtual memory uses 386 paging by mapping 4M logical space to discontinual physical space MEMORY MANAGER May 28, 2015 Ribić-Salihbegović/ETF Sarajevo 15
  • 16. • Cooperative multitasking • setjmp macro makes context switch • schedule() routine calls Round Robin void schedule(void) { unsigned prev; static int cr0; prev = current; do { current++; // round-robin switch to next task if(current >= NUM_TASKS) current = 0; } while (g_tasks[current].state!=READY); idlecpu=(prev==current==0); if(setjmp(g_tasks[prev].regcontext) != 0) return; ActivatePaging ( g_tasks[current].pagetable); longjmp(g_tasks[current].regcontext, 1); } PROCESS MANAGEMENT May 28, 2015 Ribić-Salihbegović/ETF Sarajevo 16 Remember Switch
  • 17. • Since the scheduler is of the cooperative type, the system calls are, beside the basic function, extended with the call to scheduler, as in the following example: int _OpenFile(char * name) { int i=OpenFile(name); schedule(); return i; } SYSTEM CALLS May 28, 2015 Ribić-Salihbegović/ETF Sarajevo 17
  • 18. • After several explained layers, main program started with different test TESTS May 28, 2015 Ribić-Salihbegović/ETF Sarajevo 18
  • 19. • 2 possible approaches: •Change order of the course and introduce concepts together with layers •Classic order, and example in the last week • Now used as example instead previously used oln linux or Minix • Much greater level of understanding • 90 minutes enough to explain the whole source code • Contribution to demistify Operating systems CHANGES IN EDUCATION PROCESS May 28, 2015 Ribić-Salihbegović/ETF Sarajevo 19
  • 20. • Minimalist operating systems do not strive to be used in real world applications, but can be of great importance as an educational tool to display the principles of operating systems structure and organization. • Making use of the simplest algorithms, the developed operating system kernel has fulfilled its objective and purpose, to illustrate the practical side of the operating systems role and inner working, while not spending too much time on its explanation, at the expense of theoretical considerations and approaches. Conclusion May 28, 2015 Ribić-Salihbegović/ETF Sarajevo 20