Archive for May 2016

A Few Semaphore Based Programming Problems

I’m a big believer in practice when it comes to learning programming techniques. Although this seems obvious, it tends to go against the grain for most developer/teachers (like me) who love cool projects. What’s the best way to learn (say) scheduling? Write a scheduler! Our students did write a scheduler in OS, but they probably spend 90% of their time dealing with weird C mistakes and about 10% actually thinking about scheduling. More importantly, they only wrote 1 scheduling algorithm. If you really care, they have to write 10 scheduling algorithms. I didn’t care that much about them being able to code schedulers, but I did care about them being able to use semaphores. So I needed a bunch of tiny semaphore assignments. I’m sure I’m not the first teacher to do so, but I couldn’t find ones online when I looked.

So here’s a bunch of small problems that use semaphores. Some of these I used as 2 semaphore homework assignments, some of these I used as semaphore exam questions. If I were to try and arrange them easy-to-hard, it would be: threeAndTwo, abcd, hammerAndSaw, littleRedHen, balloon, printerQueue, producerConsumer, pair. Solutions are available too, if you email me.

Thanks to Ian Ludden who write littleRedHen and balloon for me. Also, a shout out to Allen B. Downey who’s awesome free book The Little Book of Semaphores is maybe the best treatment of the topic I’ve seen. I would love to go through that entire book in my class, but there’s not enough time in the current incarnation.

If you have any problems of your own, please send them my way! My students could use the practice!

(Contains 10 attachments.)

1-credit course in GIT

This spring I decided to try something I’ve been mulling over for a long time – a 1-credit course in GIT. 1-credit CSSE classes at Rose tend to be minor affairs…generally just for student fun and not affecting graduation. Of course, we already use git in many classes at Rose-Hulman, but you usually can’t cover anything in more detail than basic checking-in, checking-out, and conflict resolution.

10 classes was a bit on the longish side…I think you definitely could have done the topics in 7ish-classes if you wanted to compress, and the curriculum will always tighten with time. I do think that it’s wishful thinking to expect students to be good at git with just a lecture or two and some sort of highly structured tutorial.

The design of the course also was a challenge. Lecturing about command line tools is not usually effective – you have to use it to get good. I toyed with the idea of making a series of broken repo states that the students would have to fix/debug, but decided it would be too much work (if anybody would like to help me by make a library of 45 or so….feel free to get in contact with me, I still think that could be good). What I decided on was lectures, supplemented by a textbook (Git Pro), followed by weekly programming assignments were students had to write scripts that used git commands (and parsed the output). This was a course for moderately senior students who had used the basics of git and could pick up a new scripting language easily.

Git homework assignments:

  • Plumbing 1 – grep for strings in particular trees (apparently git grep does this automatically but no matter)
  • Plumbing 2 – make a commit history from a series of SHAs
  • Reset and Stash – 3 little scripts involving the commands
  • Merging – automatically merge two branches in a crude way
  • Rebase – rebase but show what commits change shas
  • History Rewriting – a simple interactive rebase and a use of filter branch
  • Branches and Push/Pull – pull all local branches to a remote
  • .gitconfig – write your own gitconfig

(solutions are available if you email me)

Overall, I thought it worked pretty well. I’d like to maybe refine a few of the assignments and maybe get some more in class activities. I’d even like to do an “exam” – probably not for student credit, but just so I can assess how well this is all working.

The students also generally seemed to enjoy the class (well, I had a few drop out because they didn’t want to do the homework, but that didn’t stress me out particularly much). I’ll know a little more when student evals come back in a few weeks.

My complete lecture notes are here, if you’d like to use them for something.

Anything I missed that you would cover in your 1-credit git class? Any great ideas for assignments (they should be easy to code, and exercise the commands under question well)? Comments welcome!