490 likes | 668 Views
.NET and the SSCLI as the basis of a Distributed Systems Masters Degree. Rob Miles. University of Hull, UK. Overview. Where in the world is Hull? Teaching Undergraduate Computer Science Traditional approaches Challenges and opportunities Making a .NET-based degree
E N D
.NET and the SSCLIas the basis of aDistributed Systems Masters Degree Rob Miles University of Hull, UK
Overview • Where in the world is Hull? • Teaching Undergraduate Computer Science • Traditional approaches • Challenges and opportunities • Making a .NET-based degree • Background, aims and content • The role of .NET, SSCLI (Rotor) and AA programmes • Example laboratory exercise • Where we are now
Land of Ice & Snow The Pond Here be Dragons Centre of the Universe The World According to Us • Hull is in England, east of York and further east of New York!
What is special about Hull? • Hull: • Is a busy port city with direct connections to mainland Europe • Around 265,000 inhabitants • Is the birthplace of anti-slavery campaigner William Wilberforce • Is the home of one half of the Humber Bridge • Is the cucumber centre of Europe!
What about the University of Hull ? • Founded in 1927 – 75 this year! • 15,000 students from 100 countries • Broad arts and science focus • Graduates amongst the most employable in the U.K. • Famous for… ? • Inventing liquid crystal technology • The poet Philip Larkin, University librarian for over 30 years
Computing @ Hull • ~ 580 undergraduate students, • ~ 60 taught/~ 40 research postgraduates • Undergraduate degrees • Computer Science, Software Engineering, Business Information Engineering, Internet Computing, Games Development • Taught postgraduate degrees • Graphics and Visualization, Games Programming, Internet Computing
Undergraduate Computer Science • Our approach is fairly conventional: • Year One • Introduce broad range of underlying theory • Year Two • Extend Year One theory with more advanced topics and greater depth of content • Year Three • Individual specialism and further advanced topics • Large individual software project • Our graduates have a broad range of skills which will serve them well in the future, but these are not fully developed
The Challenge • Three years is not enough time! • To achieve this breadth of coverage we tend to lose the depth • We do not have time to expose the students to large systems and appropriate development techniques • We have little opportunity to give students all the testing/debugging skills needed by industry
The Inspiration • At a Microsoft .NET event we were introduced to Rotor • Rotor is a freely available version of .NET in source form which: • runs on Windows, FreeBSD and MacOS • is properly known as the Shared Source Common Language Infrastructure • We reckoned we could teach some serious Computer Science with this!
The Result • In September 2003 we begin teaching the .NET MSc in Distributed Systems Development • This degree: • is a world first, developed in conjunction with Microsoft UK and the Rotor product team • is a response to the challenges we face at the undergraduate level and the skills that employers require • uses Microsoft .NET to explore distributed systems concepts • uses Rotor to explore the design and implementation of modern languages and distributed computing environments • offers in-depth development of testing and debugging skills using the Rotor source as an example of a large, commercial-quality software system
.NET Degree – Aims & Content • Aims • Give advanced coverage of modern distributed computing techniques • Develop skills in working with large codebases • To develop “active practitioners” • Provide hands-on practical experience underpinned by advanced theoretical concepts • Designed in conjunction with Microsoft, but taught as a genuine academic course
Degree Structure • Three stages: • Certificate Stage • Skills to underpin the original work • Diploma Stage • Advanced computing topics • Masters Stage • Practical deployment of techniques
Masters Stage • Large, individual project based on real-world problem using Rotor or other commercial-grade software • Examples • FORTH implementation • Custom Garbage Collection • Custom Remoting / object mobility • Code profiling
The Role of .NET and Rotor • .NET provides an overreaching example of distributed systems concepts/techniques • Rotor provides • “down to the metal” implementation details • excellent environment for enhancing testing/ debugging skills • Not simply a .NET degree • The techniques which are learnt can be applied in any area
Teaching Debugging • Some things you have to do before you get good at them: • You can read about riding a bike, but this will not necessarily help when you get on one! • Debugging is like this • We see the ability to fix broken programmes as an essential skill for Computer Scientists
The Art of Debugging • Teaching what to do when it all goes wrong is difficult • Students will have had to debug their own programs but do not spend much time debugging other peoples • In our course we set the “worst case” scenario: • There is a problem with the underlying implementation • Their program is fine, but it still doesn’t work!
A Rotor-based Laboratory Exercise • A live demo • A debugging exercise from the Extensible Systems module designed to: • get the students thinking about all aspects of the compilation/execution cycle (challenges some pre-conceptions?) • provide opportunities to develop debugging and testing skills • familiarise the student with the Rotor code and the techniques used to implement it
A Simple Sort • Student are asked to write a C# program to bubble sort the following numbers static float[] data = {45.0, 6.5, 435.2, 22.0, 6.3, 100.1, 0.02, 99.9, 45.0, 17.4, 56.4}; • Being kind people, we even suggest an algorithm • Simple bubble sort
Run the sort with ROTOR • Compile and run the program using the Rotor C# compiler and the Rotor CLR: csc bubblesort.cs clix bubblesort.exe • Not a happy ending! • Something is causing our program to do bad things
Finding out more • We can use the ROTOR debugging tools to find out more about the problem: cordbg bubblesort.exe cont print • We notice that var1 (which is i) has the deeply suspicious value of 10 • The 10+1th location is beyond the array
Whose fault? • At this point the students have to decide if their code is at fault • Inexperienced programmers are prone to problems with array bounds • First they must convince themselves that their program is correct • They will not expect the language implementation to cause problems
Prove the environment • Can we verify the correctness of the code in any way? • Use Visual Studio 2003 • Hypothesis • if it works our code must be valid • Outcome • The program works correctly in this environment
First conclusion Conclusion: • Something about the Rotor environment or C# compiler causes the problem • Hypotheses • Something is wrong with the implementation of for loops? • Something is wrong with the < operator?
Isolating the fault • We need something to further isolate the problem • We have created a program which test the value of the control variables on for loop completion: csc testfor.cs clix testfor.exe • Aha! We have a smoking gun..
What could be wrong? • Something is definitely not right… • Hypothesis • The C# compiler generates Common Intermediate Language code. Perhaps the code generation is incorrect. • Use ildasm to disassemble the compiler output to see if this hypothesis is correct: ildasm testfor.exe > testfor.il
A look at the code • IL_0017 looks deeply suspicious • It looks remarkably like IL_0079 which is the code for the <= test • We can propose the hypothesis that the compiler may be producing the wrong code for the < operation in loops • We need to find a way to test this
Round Tripping • One of the great things about ROTOR is the tool set • We can fix the “bug” and re-assemble the assembler produced by the disassembler Ilasm testfor.il clix testfor.exe • The code passes the tests now
When compilers go bad • The compiler is outputting the wrong instruction for <. Why? • The parser may be mistaking < for <= • but the ROTOR C# compiler is supplied with a pre-built parser (which we can’t break!) • The code generation is sending out the wrong instruction for < • we should test this first
Stepping the compiler • We can use Visual Studio to step through the compiler and examine the source • This is a slightly fraught process, but worth doing: devenv /debugexe %TARGETCOMPLUS%\csc.exe bubblesort.cs • Make sure no solution is open before you do this! • We are now inside the compiler
Code Generation • We don’t have much time for this, but the code is generated by a method called genBlock (ilgen.cpp:754) • This traverses a tree of statements • genStatement (ilgen.cpp:874) drops out the statements themselves • It is driven by a switch which selects other methods
Generating Conditionals • genCondBranch (ilgen.cpp:1931) has the switch which controls the production of conditional branches • This uses a look up table called ILcjInstr (ilgen.cpp:2011) to get the opcode to be produced • If this array was wrong, the opcode would be wrong too
The villain of the piece • We can add print statements to find out what the values of the array indices are when the program runs • However, if we find the declaration of this array (ilgen.cpp:5598) we notice that one of the opcodes doesn’t look right • There is a CE_BLE where there should be a CE_BLT
Fix and test • We can test this by fixing the array and rebuilding the compiler • Exit from VS first! pushd \sscli\clr\src\csharp build popd csc bubblesort.cs clix bubblesort.exe
Good News, Bad News • It still doesn’t work • But the fault is different • This time the program just hangs • Hypotheses • If our source code is correct and the generated IL is correct, the Rotor CLR must be malfunctioning • The malfunction relates to the < operator.
True Grit • This is where we really find out who the stars are! • Does the comparison test fail for different data types (e.g. integers)? • No – the error only occurs in floating point comparisons. Note that compiler turns < into bge_un_s • Perhaps this is being obeyed incorrectly
More detective work • We have the CLR source – where do we begin? • The CLR has a JIT compiler which • compiles IL to native code on the fly • would be a good place to start looking • perhaps something goes wrong in JIT’ing the comparison • Which source file(s) contain the JIT compiler?
Inside the run time system • Are there any references to BGE_UN_S? • Yes - a switch statement in with opcodes (fjit.cpp:2958) • Manually trace all calls from here • End up in CLT_R8_helper at (fjitdef.h:3860) which implements the comparison • has an error – ‘<=‘ should be ‘<‘
Final Fix • Solution • Alter the <= to < • Recompile and test pushd \sscli\clr\src\fjit build popd clix bubblesort.exe • Success! All our tests and the bubble sort now work
Process • This exercise uses Rotor to confront some of the student’s preconceptions. • Most new graduates would: • Not produce sufficient test cases to narrow the problem down to the floating point comparison • Not suspect the compiler of producing incorrect code • Think that they had not fixed the compiler after removing the bug • The Rotor source is large and unfamiliar – exactly what they will face in the real world
Learning Outcomes • Importance of methodical approach • Design of test cases • Navigation of code base • Debugging tools • Disassembly tools • An introduction to intermediate language • Just-In-Time compilation
Where we are now • We have had a very good response to the course • We are presently accepting our first cohort onto the course • There are some “interesting” issues • the sscli directory is over 560MB • we need to give one of these to each student in a way that they can use it!
Working with Microsoft • Access to Microsoft Engineers • Helped us with technical aspects of the material • Helped us ensure that the content of the course is directly relevant to the needs of industry • Microsoft have been unstinting in their assistance to set up this new course
Microsoft Programmes • Microsoft are making our job easier • MSDN AA • Makes most Microsoft tools freely available to staff and students for teaching/research purposes • Shared Source Programme • Gives us access to source code of key products (e.g. operating systems, SSCLI)
Summary • We feel that our .NET degree will significantly enhance the abilities of students and build on an undergraduate course • The involvement of Microsoft is crucial • We are really looking forward to starting this course (and a bit scared…)
..and on a lighter note: Microsoft .NET and its Impact on the Cheese Industry www.lectureinrhyme.com