HTML

The MCLI HTML on-line tutorial, http://www.math.unm.edu/writingHTML/tut/lessons.html, is the main course material that we will be using to learn HTML (the course book chapters on HTML can be viewed as an additional and optional reference). Please go through the following lessons of the MCLI tutorial throughly: Lessons 0 to 8, Lessons 19 to 22. You may browse through the other lessons.

You may also find these Core Web Programming book slides (in pdf file) on HTML-Introduction interesting: http://notes.corewebprogramming.com/student/HTML-Introduction.pdf.

Given below are some important tags of HTML:

  1. Basic Tags:
    1. < !DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 3.2//EN// >
    2. < html … < /html >
    3. < head … < /head >
    4. < title … < /title >
    5. < body … < /body >
    6. < p > …< /p >
    7. < !- … — >
    8. < hr >
    9. < br >
    10. < b >
    11. < i >
  2. Lists:
    1. < ol >
      • list item
      • list item

      < /ol >

    2. < ul >
      • list item
      • list item

      < /ul >

  3. Graphics: < img > … < /img >
    1. Attributes for img:
      1. src=”…”
      2. align=”…”
      3. alt=”…”
      4. height=”…”(in pixels)
      5. width=”…”(in pixels)
  4. < body >
    Attributes:

    • bgcolor = #Hexstring
  5. Anchors: < a href = “…” > < /a >
    Variations:

    • < a href = “filename.html” > < /a >
    • < a href = “filename.gif” > < /a >
    • < a href = “http://…&#8221; > < /a >
    • < a name = “NAME” > Text to link < /a >
    • < a href = “#name” > Text to activate < /a >
    • < a href = “filename.html#NAME” > Text to activate <
    • < a href = “filename.gif” > < img src=”filename.gif” > Go to Document x < /a >
    • < a href = “mailto:enail-id” > Send an email to < /a >
  6. Special Characters:
    • &lt
    • &gt
    • & amp
  7. Special Effects:
    • < blink >
    • < marquee >
  8. Elements of Style:
    • < font > Text goes here < /font >
      Attributes:

      • size = N ( 1 <= N <= 7 )
      • size = +N
      • base font size=N
      • color = #Hexstring
      • sup
      • sub
      • face = “Font Name(s) ( list )”
    • < hr >
      Attributes:

      • size = N
      • width = x%
    • < p >
      Attributes:

      • align = center | left | right
  9. More Graphics…
    • < img src = “filename.gif | jpeg etc.” >
      Attributes:

      • alt = “Text to be displayed”
      • width = N
      • height = N
      • vspace = N
      • hspace = N
  10. Tables:
    • < table > … < /table >
      Attributes:

      • border=X
      • cellpadding=X
      • cellspacing=X
      • bgvolor=#Hexstring

    Elements of Table:

    • < tr > … < /tr > Table Rows.
    • < td > … < /td > Table Data.
      Attributes:

      • colspan=X
      • Rowspan=X
      • background=”filename.gif | jpeg etc.,”
      • width=x%
  11. Images : with & without borders.
  12. Bullets for UnOrdered Lists: type attribute.
  13. Image Maps:
    • < map name=”…” >
    • usemap:”#…” (to be used as an attrubute in the img tag)
    • < nomap >
  14. Meta Tags:
      Attributes:

    • Refresh, Content
    • Descriptive Tags
      • < name=”Decription” content=”…” >
      • < name=”keywords” content=”…” >
  15. Anchors: < a href=”URL” target=”window-name” >
    1. Attributes
      1. _top
      2. _blank
      3. < base target=”window-name”>
  16. Frames: < frameset rows=x% | N-pixels >
    1. < frame src=”URL1″ >
    2. < frame src=”URL2″ >
    3. < /frameset >
    4. < NOFRAMES > Text to be displayed < /NOFRAMES >
    5. Nested Frames
    6. Attributes for frames
      1. scrolling=no
      2. name=”window-name”
  17. Javascript: < script language=”Javascript” > THE SCRIPT GOES HERE < /script >
    1. alert(“Alert Text”)
    2. Objects:onclick=”…Javascript to do…;return True|False”
    3. onMouseOver=”…Javascript to do…;return True|False”
    4. onMouseOut=”…Javascript to do…;return True|False”
    5. document.write(“text to append to the document”)
    6. window.open(“URL”, “window-name”,”window-options”)
Advertisements

Java Web Programming (including HTML) – 2005 Course Report

This course was taught by me only once in 2005, if I recall correctly, for IInd M.Sc. (Maths) students in a deemed university in Andhra Pradesh, India. Unfortunately I have not been able to locate a record of the assignments given to the class. Therefore I decided to provide a course report using whatever data I have of the course and used my recollections as well as thoughts as I went through the course book and course book slides to add suggestions for assignments as well as a mini-project at the end of the course. [I clearly recall that students did do a mini-project at the end of the course which most, if not all, students found to be very useful in giving them confidence to do future small shopping-cart type web applications using Java servlets and JDBC+database.]

Pre-requisites for the course: It so happened that students of this course had studied C and C++ languages but without much exposure to exception handling in C++. Students also had studied a database theory course and an SQL lab. course. So C++ or other object oriented language, relational database theory and SQL are pre-requisites for this course.

Main Course Book: Core Web Programming, Second Edition by Marty Hall, Larry Brown. This book is now obsolete as can be noted from its website here: http://www.corewebprogramming.com/. Pdf versions of the book may be available on the web. I must also state that the chapters of the book that are used in this course seem to me to be relevant even today. But as I have not taught Java Web programming after 2005 and not had any other reason to keep up with this area, I cannot be absolutely sure about it.

Course Notes

The HTML part (excluding HTML Forms) of the course is done first. Here is the related material.

Next we study those parts of core Java that are different from C++, note the important parts of core Java that are similar to C++, study HTML Forms, and study web server-side Java programming, using the main course book.

  • Chapter 6. Getting Started with Java. Slides in pdf format: http://notes.corewebprogramming.com/student/Java-Introduction.pdf
  • Chapter 7. Object-Oriented Programming in Java. Slides in pdf format are http://notes.corewebprogramming.com/student/Java-OOP.pdf and http://notes.corewebprogramming.com/student/Java-Advanced-OOP.pdf. As students already have gone through a C++ course this chapter can be browsed through quickly but with a focus on differences between Java and C++ and explanation of new and different constructs and programming techniques in Java. The latter include:
    • Object being topmost ancestor for all classes
    • Different main function and utility classes and methods like System.out.println()
    • all objects allocated on heap; garbage collection solving the grave memory leak problem; Java using reference instead of pointer
    • Interfaces in Java being a very different and very interesting concept
    • CLASSPATH
    • packages
    • JavaDoc and comments
  • Chapter 8. Basic Java Syntax. Slides in pdf format: http://notes.corewebprogramming.com/student/Java-Basic-Syntax.pdf. This chapter can be browsed through but the following topics in it need proper study. [Please note that at the time I taught this course the students had not had much exposure to vector. list, map and exception in C++. So, if I recall correctly, I taught at least some of them in detail]:
    • Vector
    • Hashtable
    • Exposure to other collection classes of type sets, lists and maps.
    • Primitive data types being wrapped by corresponding wrapper class; parseXxx methods of such wrapper classes to convert string to underlying data type
    • Exceptions: try, catch, finally, throws, throw statements/keywords and exception class hierarchy.
  • Chapter 18 HTML Forms. Slides in pdf format: http://notes.corewebprogramming.com/student/Servers-and-Forms.pdf. The following topics have to be studied:
    • Simple FORM with GET and POST methods and how it used on a browser; Action attribute of FORM specifying URL/CGI program that will receive FORM data; URL encoding
    • CGI (Common Gateway Interface) and examples of it were covered in the course but as it seems to have become obsolete I suggest that it be omitted
    • TEXT controls including password and textarea controls
    • Push buttons including Submit button
    • Check Boxes, Radio Buttons
    • Combo Boxes, List Boxes
    • Server Side Image Maps
    • Hidden Fields
    • File Upload Control
    • Grouping controls
  • Chapter 19: Server-side Java: Servlets. Slides in pdf format: http://notes.corewebprogramming.com/student/Servlets.pdf. This is a vital chapter for Java Web programming. The following topics have to be studied:
    • Servlets get data from FORMs and send output data (e.g. HTML) to client (e.g. browser); Servlets can send dynamically generated webpages to client; servlets run on server and so may have access to server data
    • Advantages of servlets over CGI
    • Free servlet engines (e.g. Apache Tomcat) [I think I used Apache Tomcat for this (student) class.]
    • Hello World servlet; compiling and invoking servlets
    • Servlet generating HTML
    • Servlet life cycle – init(), service(), doGet(), doPost() and destroy() methods
    • Debugging servlets
    • Reading form (query) data in servlets (also called request data); name-value pairs, HttpServletRequest class and its getParameter(), getParameterValues(), getParameterNames() methods; example servlet program echoing parameters back to client
    • Reading HTTP request headers; getHeaderNames(), getHeader(), getContentLength(), getContentType() methods of HttpServletRequest class; HTTP Request headers – Accept, Authorization, Connection, Cookie, Host, If-Modified-Since, Referer, User-Agent
    • Creating the HTTP response; HTTP status code, setStatus(), Common status codes: 200 – OK, 401 – Unauthorized, 404 – Not Found, setHeader(), setContentType(), setContentLength(), sendRedirect(), addCookie(), Servlet example (Prime Number generation)
    • Session Tracking: Stateless HTTP connection, sessions provide means of storing state associated with a client on the server using cookies or URL-rewriting, HTTPServletRequest class methods – getSession(), Hashtable-like mechanism to hold session data, setAttribute(), getAttribute(), isNew(), shopping cart and access count examples for session data
  • Chapter 22, JDBC. Slides in pdf format: http://notes.corewebprogramming.com/student/JDBC.pdf. This is a vital chapter from the point of view of database interaction with servlets (and JSP). The following topics have to be studied:
    • JDBC API – a standardized API to interact with (access) relational databases, JDBC Driver Manager, java.sql package
    • JDBC data types and their mapping to Java data types
    • Using JDBC: Loading JDBC driver, defining connection URL, establishing database connection – Connection class, creating a database statement – createStatement() method of Connection class returning object of Statement class, executing SELECT sql statements using executeQuery() method of Statement class which returns object of ResultSet class, executing INSERT, UPDATE and DELETE sql statements using executeUpdate() method of Statement class, Processing ResultSet (in short, details to be covered later), closing the database connection using close() method of Connection class, example code doing all these operations
    • ResultSet class: next() method to (attempt to) get next row, getXxx() method where Xxx is a Java type (int, double, string, short, long etc.) which takes in a column Name or column index and returns the associated value for the specified column in the current row in the ResultSet, MetaData methods like getColumnCount(), getColumnName();
    • PreparedStatement class for parametized SQL, CallableStatement class for database stored procedures
    • SQLExceptions
    • Transactions using JDBC
  • Chapter 20, Java Server Pages (JSP): Quick introduction to JSP (No time for detailed study). Slides in pdf format: http://notes.corewebprogramming.com/student/JSP.pdf

 

Class Assignments and Mini-Project

As students go through the various chapters of the book given above (and the HTML tutorial), students are expected to try out the examples given in these chapters (and HTML tutorial), make some small variations, demonstrate them to the teacher and provide a report of these activities. The assessment of this part of the course would be based on these demonstrations and reports.

The main hands-on work in this course should be a mini-project for which significant time, say around a quarter of the time period of the course, should be provided. The mini-project should involve teams of four or five students doing a mini-project together, but with each student providing a separate report detailing his/her contribution to the mini-project. The mini-project problem is left to the students but the scope is controlled by the teacher to make it doable in the time allotted for the mini-project.

One example of a suitable mini-project is a hostel food stall with database tables containing the details of various food items on offer, their availability, their rates etc. and table(s) to hold orders from students as well as track the status of the order. The web interface of the food stall must be attractive but driven by the underlying database data. Session tracking should be used to handle a shopping cart for students that place an order on the food stall and then track the order’s fulfillment status.

Making the Linux Kernel For Fedora 7 – Instructions and Log

[This post has been created from documents last updated in Feb. 2008]

Making the Linux Kernel For Fedora 7 – Instructions

1) rpm -ivh kernel-2.6.21-1.3194.fc7.src.rpm

(Ignore kojibuilder errors)

2) rpm -ivh sparse-0.4.1-1.fc7.i386.rpm

3) rpmbuild -bp –target=$(uname -m) /usr/src/redhat/SPECS/kernel-2.6.spec
Now have a look at the /usr/src/redhat/BUILD directory. It will have two source trees under a kernelxxx directory.

4) cd /usr/src/redhat/BUILD/kernel-2.6.21/linux-2.6.21.i686

6) If you want to save the current .config then copy/rename it as say .saveconfig. Run ‘make mrproper’ (which among other things, deletes .config).

5) cd to configs/ and then copy kernel-2.6.21-i686.config to ../.config OR use saved config file by renaming it to .config

7) Run ‘make menuconfig’. Change configuration as desired
If X-Windows is available then you can run ‘make xconfig’ instead.
See impact of selections here in the remarks on make modules_install (13).

8) Run ‘make dep’ to set up dependencies. [Seems that this step is not required for 2.6 kernel; was required for 2.4 kernel. But run it anyway.]

9) Run ‘make clean’ to prepare the source tree for the build.

10) Ensure that Makefile in linux-2.6.21.i686/ has ‘EXTRAVERSION=something’. This something is appended to the kernel file that is created and so helps in differentiating between current kernel and newly created kernel. This something is also used as a library name for the modules created in the new build.

11) Run ‘make bzImage’ to make the new kernel (vmlinux) [Takes a long time]
Check the size of the vmlinux file (kernel file) that has been created.

12) Run ‘make modules’ to make the new modules. [Takes a very long time]

13) Run ‘make modules_install’ to install new modules in proper path (/lib/modules/<kernelversion>/kernel/drivers
For a config where no changes were made while running make menuconfig, the /lib/modules/<kernelversion>/ directory reported a size of around 441 MB whereas the installed FC7 kernel on my VM (probably default options) had a /lib/modules/<kernelversion>/ directory of size around 52 MB.
And, obviously, the ‘make modules’ command for ‘no changes while running make menuconfig’ config took a huge amount of time. Maybe 1.5 to 2 hours.
So it is very advisable to spend some time at the ‘make menuconfig’ stage and drop the obviously unnecessary modules (for our needs) from the kernel (modules) build.

14) Run ‘make install’ to copy new kernel and its files to proper location.
For my kernel build, the command reported ‘end_request: I/O error, devfd0….’ but it seemed to have copied the kernel to the /boot location. So things may be OK even with the reported error.

15) Verify that /boot directory contains a vmlinuz (compressed version of vmlinux) file whose filename contains the custom kernel version number (picked up from EXTRAVERSION of Makefile)

16) Verify that /boot directory contains an initrd file whose filename reflects the custom kernel version.

17) Verify that /boot/grub/grub.conf has an entry for the custom kernel

Now you are ready to reboot. From the boot (grub) menu choose the custom kernel and try it out.
Note that you can use ‘uname -r’ command to confirm that your custom kernel is running

Log of other attempt(s)

Later I created another kernel but a minimal one. Went through same procedure on existing .config file (and so of prep kernel). Started with ‘make mrproper’ step. Unusually though ‘make menuconfig’ on existing .config file showed a sensible set of options chosen (as against almost all options for prep kernel). I expected existing .config file to show almost all options selected as that is how I ended up with 441 MB of modules!! Gave kernel suffix as min1 (in Makefile as well as in one of the ‘make menuconfig’ options. The .config file has been saved in the FC7 directory as .config.min1 (To be done)

a) ‘make bzImage’ took 10 minutes.
b) ‘make modules’ got over very fast (Maybe less than 3 minutes)!!!! Only a few modules (smb, mymodule etc.) got made. When I checked the .config file the =m option was only for SMB_FS. Maybe that’s why it got over so fast. Have still not understood how the config file is so vastly different from the first (prep) kernel one, though I don’t seem to have made any significant changes while running ‘make menuconfig’. SMB_FS was one of the changes and it got reflected in the build.
When I ran ‘make mrproper’ it gave some CLEAN xxx messages and took quite some time. ‘df’ reported much higher free space after ‘make mrproper’ finished. So I do think that old modules would have got deleted as part of ‘make mrproper’. The ‘make clean’ step ran very quickly (probably because ‘make mrproper’ had done the cleaning).
c) ‘make modules_install’ finished in a few seconds. It created a dir /lib/modules/2.6.21-min1min1 (I guess min1 appears twice due to Makefile entry as well as config entry).
/lib/modules/2.6.21-min1min1 occupies just 136 KB!!!!.
Contrast this with /lib/modules/2.6.21-1.3194-fc7 occupying 57268 KB.
And with /lib/modules/2.6.21-prep occupying 441108 KB.
d) Booting into new (min1min1) kernel failed!!!! After uncompressing Linux it gave an error:
‘powernow-k8: BIOS error – no PSB or ACPI _PSS objects’
and then just froze.
The powernow-k8 error appears on other kernel boots (checked with prep kernel) as well. So that is not be the problem.
Maybe I need to do a kernel rebuild from the rpmbuild step and not the ‘make mrproper’ step.

Noticed that ‘make mrproper’ deletes .config file!!!! So the copy from configs/kernelxxxi686.config is useless. Running ‘make menuconfig’ creates a .config file with those minimal options. Last time I had changed some entries. This time I will leave it untouched and try building kernel again.
Failed again. But this time there was a message prior to the powernow-k8 message saying something about processor not being Intel. I need to check the config file.

Config file mentioned processor as Pentium III. Changed it to AMD in make menuconfig and am trying ‘make bzImage’ again.
Failed again with same message: (microcode: CPU0 not a capable Intel processor followed by powernow-k8 message and then freeze).

I guess I need to repeat the steps right from step 1 (rpm install of source followed by rpmbuild).

Deleted min1 kernel files and /lib/modules files. Emptied redhat/BUILD and redhat/SOURCES and redhat/SPECS directories.
Am now starting at step 1.
Step 3 (rpmbuild) creates a .config file in BUILD/kernxxx/linuxxxx directory. diff between this .config and configs/kernxx-i686.config gave only one extra line in former ( # i386). Renamed .config to .config.orig and carried out step 5 (copying configs/kernxx-i686.config as .config)

‘make mrproper’ deleted .config file!!! So earlier step 5 work was undone!!! So maybe this is the problem step. RH9 kernel needs this but the IBM tutorial for FC7 does not mention this step.

‘make menuconfig’ gave a set of options (maybe its default as there was no .config file). Saved these options. diff between new .config and .config.orig threw up lots of difference. One key difference was that .config had CONFIG_MPENTIUMIII=y whereas .config.orig had CONFIG_M686=y.
I think this is the incorrect specification that tripped up the earlier min1 and min1min1 builds.

Am deleting .config and copying .config.orig as .config. then will run ‘make menuconfig’ again.
Yes. The options in menuconfig match with what I had seen in the prep build. So looks like I may not have done the ‘make mrproper’ step while doing the prep build.
Need to reduce selections (else will have 441 MB of /lib/modules). Plan to try mv .config as .config.orig and then run ‘make menuconfig’. In default .config choose 686. Maybe this will fix problem. (Earlier I had tried AMD instead of PentiumIII – that did not work – see above notes). 686 choice is not there in menuconfig – instead the choice is for 586 or 686 which I chose and that resulted in CONFIG_M586=y spec.
Changed Makefile EXTRAVERSION to min1, make dep, make clean
Now am running make bzImage
Then ran Make modules, make modules_install (0 modules created).

make install tripped up towards end as it attempted to write to fd0. I think Floppy needs to off in VMware while running make install.

System got hung and on restart as there was a min1 option, I tried it out. No luck got same error as earlier.
Am going to try to do make install again with Floppy off.
No luck again!!! Same problem.

Next option is to use the configs/kernxxxi686.config and then run menuconfig on it. This configuration is a safe working starting point. I can then deselect items that I am sure are not needed like IrDA and Bluetooth. I think this approach has a better chance of working. Perhaps using menuconfig without any config file gives it a default set which may not be appropriate for my machine.

Tried this option out at college. /lib/modules/xxxprep takes only about 95 MB.
System goes beyond eariler point but does not find /dev/root and results in ‘kernel panic.’

Back to Home.
‘make defconfig’ creates a .config file with default values. Tried it out. The .config file created had much lesser options that configs/kernxx.i686.config. Processor chosen is Pentium III. Am trying make with the default config now.
Oops!! Got the same error as when ‘make menuconfig’ created the .config file. Makes sense as defconfig option would be what make menuconfig runs to create a base .config if a .config is not present.

BTW found that menuconfig option PentiumPro corresponds to M_686

Noted that /boot has a config file for fc7 install build. That is the same (but for 2 lines of comments) as configs/kerxxxi686.config!!!! Further the prep kernel (whose config was perhaps an exact copy of configs/kernxxxi686.config) is 1883668 bytes and the fc7 kernel is 1883604 bytes. A difference of just 64 bytes. The /lib/modules significant size difference could be due to installation options where only required modules got copied from install media to hard disk.

That means that the better way to customize kernel would be to start with configs/kernxxi686.config and try to remove some entries (as against using defconfig). Tried it out. Reduced many modules but allowed all LVM/RAID modules. Removed only modules that seemed very safe to remove. Reboot into new kernel worked!!!! Finally. Saved the config file as .configmin1-1W. vmlinuz is 1.59 M as against 1.88 M of both prep and fc7. /lib/modules is 276M as against 441M of prep and 57M of fc7 (But I think fc7 lib size is small due to some modules not being copied from distro media to disk).

Now will try to reduced some more modules.

Tried make bzImage after changing config via make menuconfig. make bzImage seems to be compiling everything. I guess changing the config file implies that all files should be made again. To be on safer side I think I should do ‘make clean’ after every config file change. To save time I have made quite a few reductions to the config file. Hope the new kernel runs.
It does!! vmlinuz is 1.50M and /lib/modules/xxxmin1 is 215M. Saved config file as .configmin1-2W
Startup threw up errors for bluetooth and something else (as its drivers are not included). some rpc stuff also gave an error but cannot link it to a missing driver. Ran ntsysv to not start bluetooth, nfslock, sendmail etc. at startup.

Have copied config files to guest and then Windows partition.

Now will try for a final reduction (am running out of time and further now I have got enough hang about it to teach the students). Worked!!!
vmlinuz is 1.42 M and /lib/modules/xxxmin1 is 72M (only)!!. Saved config file as .configmin1-3W.
Startup threw some more errors this time around. IPv6 module has been dropped and so some startup programs failed. IPv4 is present and X-Windows operates fine. Further I have been able to ftp between XP host and OS running this kernel.

There definitely is scope for further reduction in modules. But I guess I need to stop now. An interesting possibility for trying out reduction is to go through /lib/modules/xxxmin1 and check out possible candidates for reduction. To confirm possibility of reduction we can check against lsmod which will give us currently loaded modules. If it is not present there (and also does not seem to an obviously necessary module like ext3fs) then the file (xxx.ko) can be renamed and then the system rebooted. If the system starts up properly then maybe that module can be dropped from config (this assumes that kernel worries only about modules it needs during start up). This way avoids a time consuming kernel rebuild.
A comparison with lib/modules of fc7 may also help in identifying required modules. modinfo command helps in getting detailed info about modules (man modinfo for more details). In fact now I feel this technique can be very promising to reduce modules to way below 57 MB of fc7.

Note: For failed boots I should have looked at dmesg (System log). System log has more info that what is put out on the screen during boot.

Miscellaneous Info.
0) uname -r gives kernel release. man uname for more info
a) free command shows free physical memory.
b) top command gives free memory and some more details.
c) arch command outputs processor architecture
d) Read /usr/src/redhat/BUILD/kernel-xxx/linux-xxx/Documentation/HOWTO. It is a quick intro for a wannabe Linux Kernel Hacker (Developer :-)).
Another must read is kernel-docs.txt in the same directory.
e) lsmod, insmod, modprobe, modinfo are module related commands. man them for info.
lsmod followed by modinfo module-name is a good combo.
f) /etc/modprobe.conf has some module related stuff
g) man bootparam gives info about boot parameters.
h) ???To UPDATE for FC7???kernel customization can reduce vmlinuz size to less than 1 MB. Running system takes up about 5 MB less with casual reduction during customization and /lib/modules/kernel-xxx goes down from 29 MB to around 12 to 13 MB.
Non GUI RH9 can run in 32 MB RAM quite comfortably. ?????
i) In /etc/inittab set default runlevel to 3 for console linux and 5 for GUI linux.
j) cat /proc/cpuinfo is an interesting command. Try it out.
k) lspci -v (another interesting command: lists pci devices)
l) dmesg | more shows the boot up messages.
m) cat /proc/interrupts shows enabled interrupts. man proc details the information accessible from the /proc pseudo filesystem.
n) ntsysv is the text mode command for controlling services startup/configuration.
o) Read /usr/src/linux-xxx/Documentation/CodingStyle

Making FC7 modules – log

Note: The directory FC7/kern-drivers-misc (in the directory containing this file) contains the modules source code and Makefile referred to in the Notes below. Their state is as it was after all notes (points) had been carried out.

1) On FC7 kernel will all modules in default i686 config, tried out mymodule.c module suggested in IBM Linux Kernel hacking tutorial. Notes are:

a) Have to comment out #include <linux/config.h> for successful compilation
b) ‘make modules’ takes some time (around 10 to 15 minutes maybe). Perhaps the large number of modules selected has something to do with the time taken. Even if the other modules are not compiled maybe something else needs to be done which takes time.
c) make modules success results in creation of mymodule.ko module file.
d) The SUBDIRS=xxx argument to make did not work. So either one can say:

i) ‘make modules’ at the top of the build tree, OR
ii) make -C /usr/src/redhat/…. modules

e) Was able to successfully load mymodule and unload it as well.

2) Now am trying referring to variable in other kernel code from mymodule.c. Notes are:

a) After adding code to kernel (printk.c – addition of my_variable global variable), compiled kernel with ‘make bzImage’
b) To install new kernel used ‘make install’ and noted that new kernel image in /boot has current timestamp.

old version of this kernel is stored with .old suffix in /boot
grub.conf does not have additional entry for xxx.old linux kernel, as expected.

c) rebooted into new kernel. Confirmed that code change is reflected by using:

i) grep my_variable System.mapxxxx (in /boot directory)
grep lists the symbols in the new System.mapxxxx file but does not list it in the Sytem.mpaxxxx.old file

d) Added code to mymodule.c (which refers and increments my_variable symbol)
e) Ran ‘make modules’ (took 10 minutes).
f) Loaded & unloaded the module a few times. The my_variable kernel variable was getting changed as expected.

3) Wrote myirqtest.c as instructed. Notes are:

a) Compilation failed. Was able to correct compilation errors by looking at other files in drivers/misc directory. The fixes are:

i) module_param(varname, int/charp, 0644)
instead of MODULE_PARM(varname, “i”/”s”);
ii) myinterrupt function does not take the third struct pt_regs argument. i.e. only first two args (int, void *)

b) Test with irq 18 (interface eth0) succeeded. We can use any interface name, say Saieth0. cat /proc/interrupts then lists it as well.
c) Test with floppy irq (7) and timer irq (0) resulted in insmod failure with mismatch error message.
d) Test with i8042, irq (1) succeeded. Seems to be related to keyboard as pressing a key seems to fire two interrupts.
e) Ran startx to see if more interrupts are listed under /proc/interrupts once X is in operation. X did not seem to add new interrupt (handlers).
f) Under X, tested with i8042, irq(12) which seems to be mapped to the mouse. Test succeeded. Moving mouse resulted in print messages. (Had to use dmesg | tail to see the messages under X, whereas on console the messages appeared on console itself and could additionally be viewed using dmesg | tail).
g) Exited X and retested with i8042, irq(12). Succeeded again and confirmed that irq 12 was mapped to mouse.

4) Modified myirqtest.c to print interrupt count (received by this module) as well. Notes are:

a) Took only 7 minutes to ‘make modules’.
b) Tests succeeded – now the count is also printed and thereby makes it easy to know the last (10th) interrupt print message.

 

———— Old Making RH9 Kernel ———-
1) Check whether /usr/src/linux-2.4 exists.
If not then check whether kernel-source package has been installed using:
rpm -q kernel-source
If this command does not list any kernel-source package then install the kernel-source package using:
rpm -ivh kernel-source-2.4.20-8.i386.rpm

2) cd /usr/src/linux-2.4

3) From /usr/src/linux-2.4/configs copy kernel-2.4.20-i686.config to /usr/src/linux-2.4/.config

4) Run ‘make mrproper’.

5) Run ‘make menuconfig’ (from /usr/src/linux-2.4 directory). Change configuration as desired
If X-Windows is available then you can run ‘make xconfig’ instead.

6) Run ‘make dep’ to set up dependencies. [Takes some time]

7) Run ‘make clean’ to prepare the source tree for the build.

8) Ensure that Makefile in /usr/src/linux-2.4 has ‘EXTRAVERSION=something’. This something is appended to the kernel file that is created and so helps in differentiating between current kernel and newly created kernel. This something is also used as a library name for the modules created in the new build.

9) Run ‘make bzImage’ to make the new kernel (vmlinux) [Takes a long time]
Check the size of the vmlinux file (kernel file) that has been created.

10) Run ‘make modules’ to make the new modules. [Takes a very long time]

11) Run ‘make modules_install’ to install new modules in proper path (/lib/modules/<kernelversion>/kernel/drivers

12) Run ‘make install’ to copy new kernel and its files to proper location.

13) Verify that /boot directory contains a vmlinuz (compressed version of vmlinux) file whose filename contains the custom kernel version number (picked up from EXTRAVERSION of Makefile)

14) Verify that /boot directory contains an initrd file whose filename reflects the custom kernel version.

15) Verify that /boot/grub/grub.conf has an entry for the custom kernel

Now you are ready to reboot. From the boot (grub) menu choose the custom kernel and try it out.
Misc
——–
0) uname -r gives kernel release. man uname for more info
a) free command shows free physical memory.
b) top command gives free memory and some more details.
c) arch command outputs processor architecture
d) /usr/src/linux-xxx/Documentation/modules.txt gives good info about modules
e) lsmod, insmod, modprobe, modinfo are module related commands. man them for info.
lsmod followed by modinfo module-name is a good combo.
f) /etc/modules.conf has some module related stuff
g) man bootparam gives info about boot parameters.
h) kernel customization can reduce vmlinuz size to less than 1 MB. Running system takes up about 5 MB less with casual reduction during customization and /lib/modules/kernel-xxx goes down from 29 MB to around 12 to 13 MB.
Non GUI RH9 can run in 32 MB RAM quite comfortably.
i) In /etc/inittab set default runlevel to 3 for console linux and 5 for GUI linux.
j) cat /proc/cpuinfo is an interesting command. Try it out.
k) lspci -v (another interesting command: lists pci devices)
l) dmesg | more shows the boot up messages.
m) cat /proc/interrupts shows enabled interrupts. man proc details the information accessible from the /proc pseudo filesystem.
n) ntsysv is the text mode command for controlling services startup/configuration.
o) Read /usr/src/linux-xxx/Documentation/CodingStyle

Minix OR Linux Kernel Lab – Some Thoughts

The following are rather frank thoughts on whether the lab. course should be on Minix or Linux kernel. This comes from a document I had prepared for discussions with other faculty in 2008.

A Ist M.Tech Lab course can be justified from two perspectives:

  • How it gives students the skills and knowledge that helps them in good implementation of research projects and IInd M.Tech projects.
  • How it gives students the skills and knowledge that helps students to get industry jobs.

Minix Lab course

  • Great and perhaps ideal for in-depth O/S teaching at University level
  • Much more elegant O/S as compared to Linux
  • Wonderful platform for O/S research projects (Linux would be perhaps too cumbersome a platform for O/S research. E.g. New techniques for scheduling may be more easily and perhaps more elegantly tried out on Minix.). However O/S research projects are not so common in Indian UGC/AICTE environment (I believe).
  • Very in-depth course. Good students would be able to handle the intensity but average students may not be benefiting much.
  • IInd M.Tech. projects may be on Linux or Sun Solaris and not Minix. E.g. Cell processor projects.
  • Perhaps only few in-depth OS companies may be more appreciative of in-depth Minix kernel exposure as against overview of Linux kernel and Linux kernel device driver exposure.
  • Most companies where students apply for jobs may have preference for Linux Kernel Device driver exposure instead of Minix Kernel exposure
  • Minix course should ideally follow course book. This helps students as they can refer to the course book to strengthen their understanding of class sessions.
  • Intel architecture exposure would be best suited for the course as the course book follows Intel arch.
  • Lab courses are the only courses (barring some minor exceptions) where students get hands-on exposure. A Lab course should focus more on what the student learns to do as against what the student learns to talk about. Minix Lab course seems to be tilted heavily on understanding Minix code as against doing hands-on assignments. Perhaps significantly changing Minix code would take too much time. Existing code changing assignments in Minix seem to be somewhat trivial.
  • Ideally Minix code understanding (and even processor and processor related code understanding) could be done as part of related theory courses (O/S or Architecture). But the theory courses may not be in a position to spare the time.
  • It would be ideal if we have a defined course content for Minix.

Linux Kernel Lab course

  • Will not be so in-depth as Minix
  • Would involve Kernel customization, writing kernel modules and device drivers. Some exposure to Linux Kernel internals but lesser than that of Minix.
  • May be helpful for IInd M.Tech. projects on Linux platform. Students may be able to explore performance tweaking of kernel. They may even be able to use development versions of the kernel (as they may have new features that their project needs).
  • Knowledge of Writing Linux Device drivers may help IInd M.Tech projects involved with devices like OCR scanners, Honeywell sensors etc.
  • Knowledge of Linux Kernel customization may help in better utilization of upcoming Cluster computing lab as the OS will most probably be Linux.
  • At job interviews most companies in Indian environment will perhaps be more impressed with Linux Kernel exposure as that may be more relevant to work they do (e.g. writing drivers). Most Indian companies employing M.Tech. post graduates may not be into intense OS development.