Paternoster of Programmers Reloaded



Download 0.51 Mb.
Page1/5
Date30.04.2017
Size0.51 Mb.
#16979
  1   2   3   4   5


Paternoster of Programmers Reloaded

C, C++, Java, Python and AspectJ Case Studies

Dr. Norbert Bátfai

Paternoster of Programmers Reloaded: C, C++, Java, Python and AspectJ Case Studies

Dr. Norbert Bátfai

Szakmai lektor: Dr. András Keszthelyi

Associate professor

Associate professor

Óbuda University





Language reviewer: Ildikó Novák

private teacher

http://www.angolora.hu http://www.angolora.hu





Author's edition

Publication date 2014

Copyright © 2012, 2013, 2014 Norbert Bátfai, PhD

The lecture notes were supported by the TÁMOP-4.1.2.A/1-11/1-2011-0103 project. The project has been supported by the European Union, co-financed by the European Social Fund.



The author endeavors to maintain and to keep the author's editions of this book, and the others in the series up-to-date. These author's editions can be found at the page http://www.inf.unideb.hu/~nbatfai/konyvek/.


Dedication

This book is dedicated to my acquaintances on social networks.


Table of Contents

Preface Error: Reference source not found

1. Introduction Error: Reference source not found

1. The Paternoster of Programmers Error: Reference source not found

2. About these lecture notes Error: Reference source not found

2.1. The environment of this book Error: Reference source not found

2.2. The courses of the book Error: Reference source not found

2.2.1. High-Level Programming Languages 1 Error: Reference source not found

2.2.2. Other courses Error: Reference source not found

2.3. About the author Error: Reference source not found

2.4. About the peer reviewers Error: Reference source not found

I. C Case Studies Error: Reference source not found

2. MINIX kernel hacking: analysing microkernel's IPC Error: Reference source not found

1. Introduction: the MINIX which acted as the detonator of open source Error: Reference source not found

1.1. The MINIX microkernel and the MINIX IPC Error: Reference source not found

2. The installation of MINIX3 system Error: Reference source not found

2.1. Installation in VirtualBox Error: Reference source not found

2.2. The first MINIX kernel hacking Error: Reference source not found

3. Analysis of MINIX3 IPC Error: Reference source not found

3.1. A solution with modifying the PCB Error: Reference source not found

3.2. Another solution by introducing a new system call Error: Reference source not found

3. GNU/Linux kernel hacking: making entries in the /proc virtual file system Error: Reference source not found

1. The monolithic kernel of Linux Error: Reference source not found

1.1. Linux kernel compiling Error: Reference source not found

1.2. Kernel modules Error: Reference source not found

2. Making entries in the /proc virtual file system Error: Reference source not found

2.1. Creating the module in VirtualBox. Error: Reference source not found

2.1.1. „Celebrating” the source code Error: Reference source not found

4. Berkeley socket API, Sys V IPC and I/O multiplexing Error: Reference source not found

1. Berkeley socket API, Sys V IPC, I/O multiplexing Error: Reference source not found

2. A simple client/server sample Error: Reference source not found

2.1. The client side Error: Reference source not found

2.2. The server side Error: Reference source not found

2.2.1. Discussing the source code of the server side Error: Reference source not found

2.2.2. Protecting the memory of the processes Error: Reference source not found

2.3. Testing of the example Error: Reference source not found

2.3.1. Testing on localhost Error: Reference source not found

2.3.2. Testing on two machines Error: Reference source not found

II. C++ Case Studies Error: Reference source not found

5. A simplified protocol of 2D RCSS Error: Reference source not found

1. Emasculation of the AI-based simulation model of RCSS Error: Reference source not found

1.1. Introducing a new positioning command for RCSS client protocol Error: Reference source not found

1.1.1. Testing of the newly introduced command Error: Reference source not found

1.1.2. The response of the simplified server Error: Reference source not found

2. The team called Debrecen Great Forest FC++ Error: Reference source not found

2.1. The implementation of the throw-in Error: Reference source not found

2.1.1. Testing the throw-in Error: Reference source not found

2.2. The introduction of the tactical lineups Error: Reference source not found

2.2.1. The implementation of the corner kick Error: Reference source not found

3. The team called Debrecen Deep Forest FC++ Error: Reference source not found

3.1. The evaluation of the team Debrecen Deep Forest FC++ Error: Reference source not found

4. The team called Debrecen Round Forest FC++ Error: Reference source not found

4.1. The additional command line arguments of the simplified server Error: Reference source not found

4.1.1. The response of the simplified server Error: Reference source not found

4.1.2. Receiving the response of the simplified server Error: Reference source not found

4.2. Introducing the usage of the online coach Error: Reference source not found

III. Java Case Studies Error: Reference source not found

6. Community consciousness net Error: Reference source not found

1. The Seventh Eye mobile game Error: Reference source not found

1.1. The Seventh Eye and the „Community consciousness net” Error: Reference source not found

IV. Python Case Studies Error: Reference source not found

7. A virtual librarian Error: Reference source not found

1. Kálmán Könyves Error: Reference source not found

1.1. The structure of the AIML files Error: Reference source not found

V. AspectJ Case Studies Error: Reference source not found

8. What is the mother tongue of the object oriented programs? Error: Reference source not found

1. An analytical weaving Error: Reference source not found

2. A robot soccer weaving Error: Reference source not found

Bibliography Error: Reference source not found
List of Figures

2.1. SEND and RECEIVE message passing primitives. Error: Reference source not found

2.2. The sender is blocked while the receiver is not ready to receive. Error: Reference source not found

2.3. The receiver is blocked while the message is not being received. Error: Reference source not found

2.4. Giving the name of the MINIX system that will be installed. Error: Reference source not found

2.5. Launching the virtualized MINIX. Error: Reference source not found

2.6. Starting the installation. Error: Reference source not found

2.7. Loading the system from disk. Error: Reference source not found

2.8. We accept defaults, mutatis mutandis. Error: Reference source not found

2.9. MINIX starts from hard disk now. Error: Reference source not found

2.10. Opening the source file kernel/main.c with vi. Error: Reference source not found

2.11. The modification of the function announce() in the kernel/main.c source file. Error: Reference source not found

2.12. The booting of the newly compiled kernel. Error: Reference source not found

2.13. The message from the kernel. Error: Reference source not found

2.14. The first step of managing packages. Error: Reference source not found

2.15. Error: Reference source not found

2.16. Printing out the size of the PCB and the size of the process table. Error: Reference source not found

2.17. Read the size of the PCB and the size of the process table. Error: Reference source not found

2.18. Extending the MINIC PCB. Error: Reference source not found

2.19. Counting massages. Error: Reference source not found

2.20. The kernel process table. Error: Reference source not found

2.21. Connecting a debug function to a function key. Error: Reference source not found

2.22. The beginning of the function uzenetszam_dmp. Error: Reference source not found

2.23. The midst of the function uzenetszam_dmp. Error: Reference source not found

2.24. The end of the function uzenetszam_dmp. Error: Reference source not found

2.25. The prototype of the function uzenetszam_dmp. Error: Reference source not found

2.26. Displaying the IPC matrix. Error: Reference source not found

2.27. List of the non-empty slots from the process table. Error: Reference source not found

2.28. An array to store the „IPC matrix”. Error: Reference source not found

2.29. Incrementing of the appropriate element of the uzenetszam array. Error: Reference source not found

2.30. This is the uzenetszam that we defined in the server layer. Error: Reference source not found

2.31. Usage of the sys_getmatrix system call that will be newly developed. Error: Reference source not found

2.32. Printing the matrix. Error: Reference source not found

2.33. Defining the sys_getmatrix macro. Error: Reference source not found

2.34. The GET_MATRIX macro. Error: Reference source not found

2.35. Supplying the do_getinfo system call. Error: Reference source not found

2.36. Displaying the IPC matrix in the second solution. Error: Reference source not found

3.1. Downloading the kernel sources. Error: Reference source not found

3.2. Making the .config with command make menuconfig. Error: Reference source not found

3.3. Setting the option Kernel .config support. Error: Reference source not found

3.4. Starting the compiling. Error: Reference source not found

3.5. Starting the installation. Error: Reference source not found

3.6. The version of the running kernel. Error: Reference source not found

3.7. The updated GRUB menu. Error: Reference source not found

3.8. The new kernel. Error: Reference source not found

3.9. Switching off the option Enable loadable module support. Error: Reference source not found

3.10. The size of the kernel image. Error: Reference source not found

3.11. The circular doubly linked list of PCBs in Linux. Error: Reference source not found

4.1. Compiling the client and the server. Error: Reference source not found

4.2. Running the client and the server. Error: Reference source not found

4.3. Checking the results. Error: Reference source not found

5.1. The LightFC++ team assembles before kick off using the move command. Error: Reference source not found

5.2. After kick off the players move using the pos command. Error: Reference source not found

5.3. Testing the throw-in: player 11 kicks the ball across the touch line. Error: Reference source not found

5.4. Testing of the throw-in: player 4 starts to move towards the ball. Error: Reference source not found

5.5. Testing the throw-in: player 4 is closer than 30 meters. Error: Reference source not found

5.6. Testing of the throw-in: player 4 has just arrived to the ball. Error: Reference source not found

5.7. Testing of the throw-in: player 4 passes the ball to player 3. Error: Reference source not found

5.8. Testing the throw-in: the ball is moving towards player 3. Error: Reference source not found

5.9. The 4-4-2 formation. Error: Reference source not found

5.10. Corner kick formations. Error: Reference source not found

5.11. Player 3 and player 6 should go to the ball. Error: Reference source not found

5.12. An opposing player gains possession of the ball. Error: Reference source not found

5.13. A portion of the soccerwindow2's log file. Error: Reference source not found

5.14. The Debrecen Round Forest FC++'s team logo in the soccerwindow2 and the rcssmonitor. Error: Reference source not found

6.1. The starting icon of the Seventh Eye. Error: Reference source not found

6.2. The splash screen of the Seventh Eye. Error: Reference source not found

6.3. The main menu of the Seventh Eye. Error: Reference source not found


List of Examples

2.1. Number of processes Error: Reference source not found

2.2. The size of the PCB Error: Reference source not found

2.3. Non-empty slots Error: Reference source not found

3.1. The contents of the PCB Error: Reference source not found

3.2. Playing the game with the current macro Error: Reference source not found

3.3. Drawing a memory map Error: Reference source not found

4.1. 30 processes, with using a paper and pen Error: Reference source not found

5.1. Placing a player beside a goalpost Error: Reference source not found

5.2. Free kicks Error: Reference source not found

5.3. Do not pass backward Error: Reference source not found

5.4. A good starting Error: Reference source not found

5.5. Create the your own XPM team logo Error: Reference source not found

6.1. Running the Seventh Eye on a real mobile phone Error: Reference source not found

6.2. The client side of the „Community consciousness net” Error: Reference source not found

6.3. The server side of the „Community consciousness net” Error: Reference source not found

6.4. A community-based exercise Error: Reference source not found

6.5. A community portal based on the mental fingerprints Error: Reference source not found

7.1. Kálmán Könyves on IRC using the Program W Error: Reference source not found

7.2. Kálmán Könyves on the web using the Program D Error: Reference source not found

7.3. Create your own chatterbot Error: Reference source not found

8.1. Weaving this aspect into ALICE Error: Reference source not found

8.2. Try this AspectJ aspect yourself Error: Reference source not found
Colophon

This book is written in the framework of the project TÁMOP-4.1.2.A/1-11/1-2011-0063.


Preface

The book that the dear reader is holding in his hands shows seven more or less well designed greater or smaller programming case studies. The level of elaboration of the examples also depends on the course in which the given example is taught. In the case of the subjects of the first three semesters of BSc studies, for example, for the course High level programming languages 1-2, the case studies are highly developed. In contrast, in the case of the latter subjects, such as C, C++ Case Studies, Programming in GNU/Linux environment, Java Case Studies and Mobile Programming only the specification of the tasks is dominant. Topics of the case studies are scattered in a broad spectrum, because C, C++, Java, Python and AspectJ examples will be shown. Even for this reason alone these lecture notes are not regarded as a programmed introduction to a given particular field of information technology.

Let's see the first case study about MINIX. For the understanding of this, the reader must be familiar with the textbook [OS]. The MINIX case study and this Tannenbaum book are very closely linked, because the case study itself is a solution of an exercise of the book [OS].

In other cases the link between the special literature and our lecture notes is not so close. However, even in these cases, close relations can be found in the environment of these notes. For example, here we only briefly outline the structure of the famous RCSS team Agent2D [HELIOS], because the detailed introduction can be found in the book entitled Mesterséges intelligencia a gyakorlatban: bevezetés a robotfoci programozásba, http://www.inf.unideb.hu/~nbatfai/konyvek/MIRC/mirc.book.xml.pdf, [MIRC]. But, we attach great importance to developing an our own RCSS team, which has been started from the sampleclient of rcssserver, therefore this example is well-developed here.

We can also find such example that was developed mainly in the environment of these notes. For example, the developing the Sevent Eye case study can be found in the book Mobil programozás, Nehogy már megint a mobilod nyomkodjon Téged!http://www.inf.unideb.hu/~nbatfai/konyvek/MOBP/mobp.book.xml.pdf, [MOBP].

Finally, it may be noted that this work can be regarded as a continuation and an extension of the lecture notes Programozó Páternoszter[PP].


Chapter 1. Introduction

We are not in a difficult situation when we need to write the introduction to this book, because the „original” Paternoster of Programmers can be a good muse for this, where in a minimalist style, the Éric Lévénez's timelines were mentioned. Now, we will try to give a more pathetic one.

„Facebook is not your friend.”

—Richard Stallman stallman.org/facebook.html

1. The Paternoster of Programmers

„A lot of people misinterpret that, as if I don't care about revenue or profit or any of those things. But what not being just a company means to me is not being just that — building something that actually makes a really big change in the world.”

—Mark Zuckerberg [FBB] David Kirkpatrick: The Facebook Effect: The Inside Story of the Company That Is Connecting the World

On the one hand, the background to the name Paternoster is the metaphor that anybody can travel some floors. It means exactly that the reader can choose an arbitrary task of current interest from the wide spectrum of the tasks of the book and is able to reproduce the solution that is also fully explained in the book Paternoster. On the other hand, the Latin name Pater noster has distinctly religious overtone, because it means the Lord's Prayer. This direction is also confirmed by the fun question asked in the lab sessions „Who can celebrate the source code”. The basic message of the usage of the name paternoster is that programmers must program every day.

But also there is one other motivation... The great ones of science give meaning to intuitive notions such as


  • changing (Newton, 1643-1727, mathematics, physics)

  • infinity (Cantor, 1845-1918, mathematics)

  • space and time (Einstein, 1876-1955, physics).

  • computability (Turing, 1912-1954, informatics).

The programming also has its own legendary hackers like Richard Stallman, Mark Zuckerberg or Linus Torvalds. But who will be the next genius who is able to give meaning to the following exciting notion standing on the shoulders of the giants. And what will be the next concept? The intuitive notion of love was reinterpreted by Jesus in the New Testament, but it has not still been developed deductively, in sense that it has no mathematical background. I believe, the most promising candidates are imagination and reality. This was the reason why the Penrose-Hameroff „Orch OR” model of consciousness was mentioned in the „original” Paternoster of Programmers [PP] as part of the introduction to quantum informatics.

Many programmers know the feeling that we really ought to write a good computer program. The root of this is that the programmers can create whole worlds in their programs. In this sense, beginner programmers have already participated in a sort of a genesis. It may be actually true for only a few professions. Programming something is a very constructive process, as Chaitin said in [METAMATH] „you understand something only if you can program it”. Based on Turing's work on computing machinery, in my humble opinion, programmers may do the next scientific conceptual breakthrough. For example, to define random infinite sequences of 0 and 1 is a hard mathematical statistical issue, but the same result is achieved, relatively easily, by using the algorithmically complexity.

When reading this book, it is important for dear readers to keep in mind that neither this book nor other books can give the excitement of writing programs. This book can be only the preliminary step in knowing the real nature of programming. First, try the examples in the book, then write your own modifications to these examples. Certainly you must work on real computers from the start of reading the book.

2. About these lecture notes

2.1. The environment of this book

This book has been continuously improved together with other books in the following series



  • Bátfai Norbert: Programozó Páternoszterhttp://www.inf.unideb.hu/~nbatfai/ProgramozoPaternoszter.pdf, [PP].

  • Bátfai Norbert, Juhász István: Javát tanítok, Bevezetés a programozásba a Turing gépektől a CORBA technológiáighttp://www.tankonyvtar.hu/hu/tartalom/tkt/javat-tanitok-javat, [JAVATTANITOK].

  • Bátfai Norbert: Mobil programozás, Nehogy már megint a mobilod nyomkodjon Téged!http://www.inf.unideb.hu/~nbatfai/konyvek/MOBP/mobp.book.xml.pdf, [MOBP].

  • Bátfai Norbert: Mesterséges intelligencia a gyakorlatban: bevezetés a robotfoci programozásbahttp://www.inf.unideb.hu/~nbatfai/konyvek/MIRC/mirc.book.xml.pdf, [MIRC].

  • Bátfai Norbert: Párhuzamos programozás GNU/Linux környezetben: SysV IPC, P-szálak, OpenMPhttp://www.inf.unideb.hu/~nbatfai/konyvek/PARP/parp.book.xml.pdf, [PARP].

  • Bátfai Norbert: Programozó Páternoszter újratöltve: C, C++, Java, Python és AspectJ esettanulmányokhttp://www.inf.unideb.hu/~nbatfai/konyvek/PROP/prop.book.xml.pdf (ez a jelen könyv).

  • Bátfai Norbert et al.: The Yearbook of the Programmers of University of Debrecenhttp://sourceforge.net/projects/udprog/, [UDPROG] (http://youtu.be/Xkdbly0ySJ8,

).

All these (only Hungarian language) books in this series try to support each other with background information and know-how. It is not too hard to organize because these books contain many common programming themes. Moreover, in many cases, it occurs that an example of one book is further developed in another one.



2.2. The courses of the book

In this section, we briefly introduce the courses that are based on using this book.

2.2.1.  High-Level Programming Languages 1

This is a fundamental and the first hard core Programming class on the software engineering B.Sc. at University of Debrecen. The programming tasks for this course can be found in an exercise workbook entitled The Yearbook of the Programmers of University of Debrecen. It can be found on Sourceforge under the project name udprog that contains the book itself in DocBook 5.1 and a git repository to maintain the source codes of solutions of exercises. But some of the exercises of udprog are developed in details here, in the present lecture notes.

Availability of the source codes and the book itself

In the spirit of „Release Early, Release Often” [KATEDRALIS], these lecture notes have already been downloadable since the beginning of its writing. It can be downloaded in DocBook XML 4.4 source format and in some other formats such as PDF and EPUB as well from the author's homepage.

The source codes were copied from this book itself for testing, so all programs will work properly, at least in theory. In addition, the usage of the source codes is shown in detail for all examples.

The evolution of the lecture notes

This book is an informatics one so its basic nature is changing. Therefore we are continuously maintaining it as an author's edition at the page http://www.inf.unideb.hu/~nbatfai/konyvek/.

2.2.2. Other courses

The examples of these lecture notes can be naturally used in other courses. For example, in the author's (only Hungarian language) courses, by the following breakdowns of exercises:


  • C, C++ esettanulmányok (Case studies in C and C++; PTI, GI M.Sc. lab), MINIX kernel IPC exercise, Linux kernel module exercise.

  • Programozás GNU/Linux környezetben (Programming in GNU/Linux environment; PTI, GI M.Sc. lecture and lab), Linux kernel module exercise, Berkeley socket API, Sys V IPC and I/O multiplexing.

  • Java esettanulmányok (Java case studies; PTI, GI B.Sc. lab), Seventh Eye, A robot soccer weaving.

  • XML, HTML (PTI B.Sc. lab), A virtual librarian.

  • Mobil programozás (Mobile programming; PTI, GI B.Sc. lab), Seventh Eye.

  • Magas szintű programozási nyelvek 2 (High-Level Programming Languages 2; PTI, MI, GI B.Sc. lecture and lab), A robot soccer weaving.

2.3. About the author

Norbert Bátfai is working as an assistant professor in the Faculty of Informatics at the University of Debrecen, Hungary. He received his M.Sc. (summa cum laude) in Computer Science in 1998 at the Kossuth Lajos University (KLTE), Debrecen, Hungary. In 1999, he won the first prize in the Java Programming Contest organized by Hungarian Java Alliance: Sun, IBM, Oracle, Novell and IQSoft. In 2004, his company won the first prize in the Hungarian Mobile Java Developer Contest organized by Sun Hungary and Nokia Hungary. In 2008, the Hungarian Chief Information Officers' Association selected him as an IT trainer of the year. He received the Ph.D. degree in 2011. He won the Pollák-Virág award from Scientific Association for Infocommunications Hungary in 2012.

2.4. About the peer reviewers

András Keszthelyi, PhD., kea@turul.banki.hu, Óbuda University.

Ildikó Novák, angoloraonline@gmail.com, private teacher, http://www.angolora.hu.



Download 0.51 Mb.

Share with your friends:
  1   2   3   4   5




The database is protected by copyright ©ininet.org 2024
send message

    Main page