Upload
others
View
0
Download
0
Embed Size (px)
Citation preview
Introducing the basics of user-‐level mul6threading
early adopters 2012
Ana Lúcia de Moura Noemi Rodriguez
amoura, [email protected]‐rio.br
mo6va6on
• importance today: – scalability and massive concurrency – overhead
• difference hard to understand with no hands-‐on experience
user-‐level X system-‐level mul6threading
cross-‐cuKng approach:
• introduce experience with user-‐level mul6threading when students learn about the execu6on stack...
Systems SoNware course
throughout this course, students are introduced to basic mechanisms that support higher-‐level abstrac6ons
Systems SoNware at PUC-‐Rio
• one-‐semester course taken by all undergraduates in Compu6ng (computer engineering, computer science, IT)
• common ground with Computer Systems but strong emphasis on soNware perspec6ve – Bryant & O'Hallaron. Computer systems: a programmers's perspec6ve.
• one-‐week modules with 2 classes each: theore6cal and lab
course site
course syllabus • data representa6on: integer and floa6ng-‐point types, arrays, structs
• IA-‐32 assembly language (basics) • transla6on of C statements and control structures
• implementa6on of subrou6nes – execu6on stack, arguments, local variables
• corou6nes • interrups and traps • linking and loading
new module: corou6nes
• mo6va6on: generators, iterators, mul6tasking M. Sco\, Programming Language Pragma-cs, Morgan Kaufmann, 2009.
• examples: Lua – simple syntax allows to concentrate on concept
• corou6ne library:
icoro_transfer
yield resume transfer
core module (in assembly)
symmetric corou6nes (in C) asymmetric corou6nes (in C)
corou6ne lab function create_task(f) – new task local co = coroutine.create(f) table.insert(tasks, co) end function dispatcher() – simple scheduler local i = 1 while true do if tasks[i] == nil then if tasks[1] == nil then break end i= 1 end local status = coroutine.resume(tasks[i]) if status == false then table.remove(tasks, i) else i= i + 1 end end end
• construc6on of a very simple coopera6ve scheduler
• specifica6on in Lua
evalua6on: • lab helps students to acquire concrete understanding of
user-‐level flows • students were mo6vated by the "under-‐the-‐
hood"approach
future plans: • extend corou6ne material to two weeks
1. students develop program using asymmetric corou6nes 2. students develop symmetric version of the library