2 years agorandom: Fix behavior of kernel option "-rs". master
Yuzhuo Jing [Sat, 29 May 2021 19:05:16 +0000 (12:05 -0700)]
random: Fix behavior of kernel option "-rs".

In init.c at line 275:
  random_init (rtc_get_time ());

The comments claim that "This has no effect if an "-rs" option was
specified." However, this line actually overrides the initialization at

To see the effect, we can try generating some random bytes after parsing
the arguments. Apply the patch file randprint.patch, I get the following
group of output w/ and w/o "-rs", and w/ and w/o simulator RTC:

Kernel command line: -q
Unix epoch is 9
 10 c4 c3 f4 1a 18 b0 cb 5f 2a 4d d5 d8 73 42 66

Kernel command line: -q -rs=1
Unix epoch is 9
 10 c4 c3 f4 1a 18 b0 cb 5f 2a 4d d5 d8 73 42 66

Kernel command line: -q -rs=1
Unix epoch is 1621759823
 60 4a 91 29 c3 d4 f5 16 96 7e c8 05 37 6f 79 4e

Kernel command line: -q -rs=1
Unix epoch is 1621759824
 c1 ac a2 a1 3c e7 83 a3 31 a9 31 3f 2d 1c fa f9

Expected output is that the last three ones has the same output, and
they should differ from the first output.

This commit fixes the problem. We check `inited` variable at the
beginning of the random_init function.

New output:

Kernel command line: -q
Unix epoch is 9
 10 c4 c3 f4 1a 18 b0 cb 5f 2a 4d d5 d8 73 42 66

Kernel command line: -q -rs=1
Unix epoch is 9
 01 48 10 d0 18 1c 6a 43 a4 19 73 08 d7 cc d3 39

Kernel command line: -q -rs=1
Unix epoch is 1621760373
 01 48 10 d0 18 1c 6a 43 a4 19 73 08 d7 cc d3 39

Kernel command line: -q -rs=1
Unix epoch is 1621760377
 01 48 10 d0 18 1c 6a 43 a4 19 73 08 d7 cc d3 39

2 years agortc: Fix Unix epoch conversion from RTC time.
Yuzhuo Jing [Sat, 29 May 2021 18:58:01 +0000 (11:58 -0700)]
rtc: Fix Unix epoch conversion from RTC time.

We can see the effect by adding two printf shown in the rtcprint.patch
attachment. Running `pintos --bochs -- -q`, I get the following output:

Time is 70-01-01 00:00:09
Unix epoch is 2678409

The expected epoch should be 9 according to the first line. The epoch we
see is 1 month behind the correct value.

Reason for this is the months to seconds calculation:

  for (i = 1; i <= mon; i++)
    time += days_per_month[i - 1] * 24 * 60 * 60;
  time += (mday - 1) * 24 * 60 * 60;

The days in that month is calculated in the last line in the snippet.
Therefore, only the days before that month in that year needs to be
counted in the for loop. We can change ‘<=‘ to ‘<‘ in the loop

After fixing this, running `pintos -- -q; date; date +%s` gives:

Time is 21-05-24 09:32:40
Unix epoch is 1621762360

Mon May 24 09:32:40 UTC 2021

There is a time difference of 1 leap day. Year 1970 was not a leap year,
but 1968 and 1972 were.

2 years agoUpdated to use Bochs 2.6.11
John Ousterhout [Thu, 15 Apr 2021 21:43:29 +0000 (14:43 -0700)]
Updated to use Bochs 2.6.11

2 years agoSmall bug fixes in gdb macros
John Ousterhout [Tue, 12 Jan 2021 23:28:24 +0000 (15:28 -0800)]
Small bug fixes in gdb macros
Fix contributed by Thierry Sans.

3 years agoUndo accidental LDFLAGS modfication from b568df7ae9
John Ousterhout [Sat, 27 Jun 2020 22:19:28 +0000 (15:19 -0700)]
Undo accidental LDFLAGS modfication from b568df7ae9

3 years agoConvert tabs to spaces in design doc templates
John Ousterhout [Tue, 19 May 2020 04:32:20 +0000 (21:32 -0700)]
Convert tabs to spaces in design doc templates

3 years agoRemove "insult" example
John Ousterhout [Tue, 12 May 2020 04:03:45 +0000 (21:03 -0700)]
Remove "insult" example
(Too many terms that may offend some people)

3 years agoMark test alarm-priority as timing-sensitive
John Ousterhout [Fri, 1 May 2020 23:56:30 +0000 (16:56 -0700)]
Mark test alarm-priority as timing-sensitive

3 years agoDocument threads tests that may fail under jitter
John Ousterhout [Fri, 1 May 2020 05:20:48 +0000 (22:20 -0700)]
Document threads tests that may fail under jitter

3 years agofsutil: Fix writing end-of-archive marker.
Ben Pfaff [Sun, 10 May 2020 15:57:52 +0000 (15:57 +0000)]
fsutil: Fix writing end-of-archive marker.

This code was supposed to write two sectors but instead it wrote the same
sector twice.

Thanks to Grant A Shurtz for reporting this bug.

3 years agoFix link errors with GCC 10 and binutils 2.34 on Fedora
John Ousterhout [Thu, 26 Mar 2020 18:28:48 +0000 (11:28 -0700)]
Fix link errors with GCC 10 and binutils 2.34 on Fedora
Fix the following compile errors:

ld: ... multiple definition of `fs_device'; ... first defined here


ld: ... multiple definition of `test_name'; ... first defined here.

These seem to result in a change in how GCC and the linker handle strong
and weak symbols.

Signed-off-by: W. Michael Petullo <>
3 years agoFix ld output with recent versions of GCC and binutils
John Ousterhout [Thu, 26 Mar 2020 17:56:00 +0000 (10:56 -0700)]
Fix ld output with recent versions of GCC and binutils
Recent versions of GCC and binutils produce programs that make use of
"Secure COde Partitioning (SCOP)" as indicated by ld's separate-code flag.
SCOP adds an additional ELF segment that bears read, but not execute,
permissions, and Pintos is unable to load programs laid out in this way.
For instance, the version of ld on Fedora 31+ seems to break Pintos'
program loading by generating ELFs with the following layout:

$ readelf -l halt

Elf file type is EXEC (Executable file)
Entry point 0x80480cb
There are 4 program headers, starting at offset 52

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  LOAD           0x000000 0x08048000 0x08047000 0x000b4 0x000b4 R   0x1000
  LOAD           0x0000c0 0x080480c0 0x080480c0 0x02699 0x02699 R E 0x1000
  LOAD           0x00275c 0x0804b75c 0x0804b75c 0x00018 0x00019 RW  0x1000
  GNU_STACK      0x000000 0x00000000 0x00000000 0x00000 0x00000 RW  0x10

 Section to Segment mapping:
  Segment Sections...
   01     .text .rodata .rodata.str1.4 .rodata.str1.1
   02     .data .bss

The failure follows from Pintos trying to load two segments (00 and
01) at the same address. The failure happens when process.c's load()
tries to load the second segment by calling load_segment(), which calls

Passing noseparate-code to ld reverts to the following ELF layout,
and this fixes the problem.

Elf file type is EXEC (Executable file)
Entry point 0x80480ab
There are 3 program headers, starting at offset 52

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  LOAD           0x000000 0x08048000 0x08048000 0x02739 0x02739 R E 0x1000
  LOAD           0x00273c 0x0804b73c 0x0804b73c 0x00018 0x00019 RW  0x1000
  GNU_STACK      0x000000 0x00000000 0x00000000 0x00000 0x00000 RW  0x10

 Section to Segment mapping:
  Segment Sections...
   00     .text .rodata .rodata.str1.4 .rodata.str1.1
   01     .data .bss

Signed-off-by: W. Michael Petullo <>
5 years agotimer: Fix timer calibration logic.
Farshad Ghanei [Wed, 28 Mar 2018 17:34:35 +0000 (13:34 -0400)]
timer: Fix timer calibration logic.

loops_per_tick calculation should get updated with loops_per_tick, not with

5 years agoFix problems compiling documentation
John Ousterhout [Wed, 28 Mar 2018 16:59:11 +0000 (09:59 -0700)]
Fix problems compiling documentation
* Two warnings (deprecated regex syntax)
* One error (couldn't find pintos-t2h.init without "./" prefix)

5 years agodoc: Fix typo.
Farshad Ghanei [Wed, 14 Feb 2018 00:45:37 +0000 (19:45 -0500)]
doc: Fix typo.

Fixed a type in the Guide, Section E.5 , Subsection E.5.1 Using GDB,

6 years agoOn newer systems -ltinfo needs to be explicitly added to the link flags
Darshit Shah [Wed, 25 Oct 2017 12:53:54 +0000 (14:53 +0200)]
On newer systems -ltinfo needs to be explicitly added to the link flags

6 years agoModify the linker script to match the generated binary
Darshit Shah [Tue, 24 Oct 2017 13:14:58 +0000 (15:14 +0200)]
Modify the linker script to match the generated binary

Newer versions of GCC (tested with GCC 7), emit more sections in the
binary. Fix the computation of the start of the BSS section to prevent
zeroing out parts of the data section

7 years agodoc: Use texi2pdf instead of pdftex.
Ben Pfaff [Tue, 26 Apr 2016 15:32:19 +0000 (08:32 -0700)]
doc: Use texi2pdf instead of pdftex.

This automatically reruns pdftex if necessary, to make sure that references
are correct.

Reported by David Eck <>.

7 years agopintos: Avoid apparent name collision in definition of SIGALRM subroutine.
Ben Pfaff [Tue, 9 Feb 2016 04:48:37 +0000 (20:48 -0800)]
pintos: Avoid apparent name collision in definition of SIGALRM subroutine.

Without this patch, modern versions of Perl issue the following warnings:

    Prototype mismatch: sub main::SIGVTALRM () vs none at
    .../src/utils/pintos line 188.
    Constant subroutine SIGVTALRM redefined at
    .../src/utils/pintos line 180.

Changing the name of the function avoids the warning.

Thanks to Geoffrey Knopf for reporting this problem.

7 years agopintos: Avoid literal control character in Perl variable name.
Ben Pfaff [Tue, 9 Feb 2016 04:47:10 +0000 (20:47 -0800)]
pintos: Avoid literal control character in Perl variable name.

Modern versions of Perl prefer a caret in variable names over literal
control characters and issue a warning if the control character is used.
This fixes the warning.

7 years agopintos: Fix undefined value warning from Perl on read error.
Ben Pfaff [Tue, 9 Feb 2016 04:46:18 +0000 (20:46 -0800)]
pintos: Fix undefined value warning from Perl on read error.

When sysread encounters an error, it returns undef, which yields a warning
when compared against 0.  This fixes the problem.

7 years agoClarified wording in design question A2 for vm jopreview
John Ousterhout [Fri, 18 Dec 2015 00:28:21 +0000 (16:28 -0800)]
Clarified wording in design question A2 for vm

(Old wording could result in answers other than the desired one)

7 years agoMake docs compile again
John Ousterhout [Thu, 17 Dec 2015 23:29:33 +0000 (15:29 -0800)]
Make docs compile again

With newer versions oF packages such as texinfo and Perl, the
documentation no longer compiled. Fixed various issues, and
removed dvi and ps from default output formats, since software
to generate them is becoming less widely available.

7 years agoUpdates for new version of qemu
John Ousterhout [Thu, 17 Dec 2015 19:38:47 +0000 (11:38 -0800)]
Updates for new version of qemu

Use new isa-debug-exit device for shutdown, switch name to

7 years agoFsutil_ls must close the directory after reading it
John Ousterhout [Thu, 17 Dec 2015 19:36:48 +0000 (11:36 -0800)]
Fsutil_ls must close the directory after reading it

7 years agoPatches to make Bochs 2.6.2 work with Pintos
John Ousterhout [Thu, 17 Dec 2015 19:33:52 +0000 (11:33 -0800)]
Patches to make Bochs 2.6.2 work with Pintos

(patches provided by David Mazieres).

7 years agoFixes exec-bound-3 failures
John Ousterhout [Thu, 17 Dec 2015 19:29:13 +0000 (11:29 -0800)]
Fixes exec-bound-3 failures

The boundary position wasn't being properly chosen (must ensure that
the dst array in boundary.c is always in the last page of the .bss

7 years agoFixed typo in docs Section (0x08084000 => 0x08048000)
John Ousterhout [Thu, 17 Dec 2015 17:48:35 +0000 (09:48 -0800)]
Fixed typo in docs Section (0x08084000 => 0x08048000)

7 years agoRemove mention of CS 107 from localsettings.texi
John Ousterhout [Thu, 17 Dec 2015 17:43:57 +0000 (09:43 -0800)]
Remove mention of CS 107 from  localsettings.texi

7 years agoSwitch docs to use Git instead of CVS by default
John Ousterhout [Thu, 17 Dec 2015 17:41:53 +0000 (09:41 -0800)]
Switch docs to use Git instead of CVS by default

Also a few minor changes to localsettings.texi.

7 years agoAdded more userprog tests, mostly relating to boundary conditions
John Ousterhout [Fri, 14 Dec 2012 22:51:09 +0000 (14:51 -0800)]
Added more userprog tests, mostly relating to boundary conditions
involving invalid pages (e.g., position system call opcode with first
bytes in a valid page and remaining bytes in a nonexistent page).

7 years agoMinor documentation updates
John Ousterhout [Thu, 17 Dec 2015 17:28:35 +0000 (09:28 -0800)]
Minor documentation updates

Fixed typos and obsolete info, removed Stanford dependencies.

9 years agoFix userprog tests for clang
Pablo de Oliveira [Mon, 17 Mar 2014 18:13:22 +0000 (19:13 +0100)]
Fix userprog tests for clang

Recent clang version, detect attemps to dereference or call NULL, and
eliminate the code.

../../tests/userprog/bad-read.c:11:9: warning: indirection of
non-volatile null pointer will be deleted, not trap [-Wnull-dereference]
        *(int *) NULL);

This patchs adds the volatile modifier as necessary.
It allows to use clang to compile the tests.

9 years agoAdd ACPI shutdown sequence
Pablo de Oliveira [Mon, 17 Mar 2014 18:01:59 +0000 (19:01 +0100)]
Add ACPI shutdown sequence

On QEMU emulator version 1.7.0, the previous shutdown sequence (writing
`shutdown` to 0x8900), is not working properly.

This patch adds support for the ACPI shutdown code which works on qemu
1.7.0 and preserves the old sequence for compatibility.

11 years agoutils/Makefile: Use LOADLIBES instead of LDFLAGS to link the math library.
Ben Pfaff [Sun, 2 Sep 2012 00:10:29 +0000 (17:10 -0700)]
utils/Makefile: Use LOADLIBES instead of LDFLAGS to link the math library.

Matthew Pirocchi <>, via John Ousterhout
<> reports that this fixes a problem on his system.

11 years agoFix gcc inline assembler operand constraints for syscall -- as pushl modifies %esp...
Benedikt Huber [Wed, 29 Feb 2012 14:17:04 +0000 (15:17 +0100)]
Fix gcc inline assembler operand constraints for syscall -- as pushl modifies %esp, variable operands must not reference the stack pointer.

Without this patch, gcc-4.6.1-9ubuntu3 miscompiles the read syscall to:
  000000b6 <read>:
    b6:   ff 74 24 0c             pushl  0xc(%esp)
    ba:   ff 74 24 08             pushl  0x8(%esp)  ; [!]
    be:   ff 74 24 04             pushl  0x4(%esp)  ; [!]

12 years agoFix boot under Bochs when Pintos is compiled with recent GCC.
Russ Ross [Thu, 25 Aug 2011 03:41:30 +0000 (20:41 -0700)]
Fix boot under Bochs when Pintos is compiled with recent GCC.

When compiled according to the instructions, bochs fails to load
the project 1 kernel.  This seems to be due to the latest gcc using an
instruction that bochs is not compiled to support.  Adding the
'--enable-cpu-level=6' configure option to Bochs, as this commit does,
seems to work.

12 years agoFix Bochs build with recent GCC.
Russ Ross [Thu, 25 Aug 2011 03:40:10 +0000 (20:40 -0700)]
Fix Bochs build with recent GCC.

bochs-2.2.6 failed to compile with the latest version of gcc.  This commit
fixes the problem

12 years agobitmap: Fix mistakes in comments.
Ben Pfaff [Thu, 10 Mar 2011 04:34:33 +0000 (20:34 -0800)]
bitmap: Fix mistakes in comments.

Reported by a student of Borja Sotomayor <>.

12 years agoMakefile: Use $(MAKE) instead of plain 'make'.
Ben Pfaff [Sat, 12 Feb 2011 18:19:28 +0000 (10:19 -0800)]
Makefile: Use $(MAKE) instead of plain 'make'.

This allows make to pass the proper command line arguments to the sub-make.

12 years agothread: Do not disable interrupts unnecessarily while initializing stack.
Ben Pfaff [Sat, 12 Feb 2011 18:04:27 +0000 (10:04 -0800)]
thread: Do not disable interrupts unnecessarily while initializing stack.

Reported by Francis Russell <>.

12 years agothread: Properly protect 'all_list' around insertion.
Ben Pfaff [Sat, 12 Feb 2011 18:03:53 +0000 (10:03 -0800)]
thread: Properly protect 'all_list' around insertion.

Reported by Francis Russell <>.

12 years agosquish-pty: Flush buffered data from pty to stdout when pty's slave closed
Ben Pfaff [Thu, 16 Dec 2010 05:42:12 +0000 (21:42 -0800)]
squish-pty: Flush buffered data from pty to stdout when pty's slave closed

When the slave side of the pty is closed, the "read" system call returns
EIO.  In this situation, squish-pty failed to flush any output that it
already had in its buffer (up to 16 bytes) to stdout.  This could cause
the "Powering off..." message printed by Pintos just before exiting to
be missing from the output.

This usually didn't happen, because there are two other exit paths from
the relay() function that does most of squish-pty's work.  The most common
exit path was (evidently) the one which detected that the child process
had died, which did properly flush the buffer.  (The third path was wrong
too, and this patch fixes that one too.)

This patch fixes the problem by using a single exit path from relay() that
always reads any remaining input from the pty (if it is open) and flushes
it to stdout.

Reported by Borja Sotomayor <>.

12 years agofree-map: Replace U+00A0 "hard spaces" by ordinary ASCII spaces.
Ben Pfaff [Sat, 11 Dec 2010 17:55:04 +0000 (09:55 -0800)]
free-map: Replace U+00A0 "hard spaces" by ordinary ASCII spaces.

Reported by Borja Sotomayor <>.

13 years agoblock: Avoid accessing past the end of the block_by_role array.
Joseph Huang [Wed, 5 May 2010 16:23:55 +0000 (09:23 -0700)]
block: Avoid accessing past the end of the block_by_role array.

13 years agoMake.config: Use a different method to detect --build-id support.
Ben Pfaff [Sat, 1 May 2010 18:20:14 +0000 (11:20 -0700)]
Make.config: Use a different method to detect --build-id support.

Some versions of ld accept /dev/null as a valid input file.  Others will
not.  The latter versions will give false negatives for --buil-id support,
which breaks linking of Pintos userspace programs.  So use a different
method, that I hope will be more reliable, to detect --build-id support.

Reported by Joseph Huang <>.

13 years agopintos: Make sure to print buffered data at end of input.
Ben Pfaff [Thu, 7 Jan 2010 17:26:11 +0000 (09:26 -0800)]
pintos: Make sure to print buffered data at end of input.

Here, $buf might have some data in it that has not yet been printed, but
we were discarding it (and trying to read more) without printing it.

(In Perl, "do" ensures that the inner block runs at least once; without
"do" the condition is evaluated first.)

13 years agodoc: Fix references to power_off() to refer to correct function and file name.
Ben Pfaff [Tue, 26 Jan 2010 17:12:50 +0000 (09:12 -0800)]
doc: Fix references to power_off() to refer to correct function and file name.

Reported by Nathaniel Hardison <>.

13 years agoSupport newer versions of QEMU, which do not have the -no-kqemu option.
Ben Pfaff [Thu, 7 Jan 2010 06:12:36 +0000 (22:12 -0800)]
Support newer versions of QEMU, which do not have the -no-kqemu option.

Thanks to David Mazieres for reporting the problem and the fix.

14 years agoFix typo in comment describing free_map_allocate().
Ben Pfaff [Sat, 14 Nov 2009 04:22:41 +0000 (20:22 -0800)]
Fix typo in comment describing free_map_allocate().

Thanks to Godmar Back for reporting the problem and for the fix.

14 years agoUse round-toward-0 instead of round-to-nearest in fixed-point example.
Ben Pfaff [Sat, 24 Oct 2009 19:10:54 +0000 (12:10 -0700)]
Use round-toward-0 instead of round-to-nearest in fixed-point example.

Rounding to nearest raises a host of issues that we don't want students
to worry about.

Suggested by Godmar Back.

14 years agoRemove unnecessary optimization barrier.
Ben Pfaff [Tue, 20 Jan 2009 06:32:57 +0000 (22:32 -0800)]
Remove unnecessary optimization barrier.

The compiler can't optimize out the load of "ticks" here because
it can't look into intr_disable() and intr_set_level() and know that
they don't modify "ticks".

Thanks to Martin <> for pointing this out.

14 years agoPrint a message instead of panicking upon an unexpected interrupt.
Ben Pfaff [Mon, 22 Dec 2008 01:37:44 +0000 (17:37 -0800)]
Print a message instead of panicking upon an unexpected interrupt.

We cannot expect that we know in detail ever interrupt that can occur
on real hardware, so we must cope with exceptional cases a little

15 years agoAvoid long pauses on serial timeout on boot on physical hardware.
Ben Pfaff [Thu, 4 Dec 2008 05:56:59 +0000 (21:56 -0800)]
Avoid long pauses on serial timeout on boot on physical hardware.

The Pintos loader writes status to the serial port as well as the
VGA console, but this doesn't work out so well on at least some
real hardware when nothing is connected to the serial port: each
character can take a second or so to display because the BIOS
waits for a serial timeout each time.  So, on the first serial
timeout, replace the "int $0x14" call by a pair of no-ops.

The rest of the changes are part of the struggle not to exceed
the maximum loader size.

15 years agoRemove MIT copyright notice and license.
Ben Pfaff [Thu, 4 Dec 2008 05:42:42 +0000 (21:42 -0800)]
Remove MIT copyright notice and license.

Pintos used to contain a loader and I/O functions derived from MIT
code, but this has now been entirely eliminated, so there is no
longer any reason to retain the MIT copyright notice or license.

15 years agoRewrite the I/O port code.
Ben Pfaff [Thu, 4 Dec 2008 05:41:18 +0000 (21:41 -0800)]
Rewrite the I/O port code.

The contents of these functions was derived from code used in the
Massachusetts Institute of Technology's 6.828 advanced operating
systems course.

I deleted the contents of these functions and then rewrote them from
scratch without reference to the earlier code, working only from the
function comments (which I wrote earlier).

15 years agoadded section "Accessing User Memory", including explanation of why
Godmar Back [Fri, 14 Nov 2008 06:13:54 +0000 (01:13 -0500)]
added section "Accessing User Memory", including explanation of why
pinning is necessary
added FAQ for why stack growth may cause page faults above stack pointer
minor edits to other sections

15 years agofixed backtrace to work with -O (now conforms to
Godmar Back [Fri, 14 Nov 2008 02:30:41 +0000 (21:30 -0500)]
fixed backtrace to work with -O (now conforms to )

15 years agoadded btthreadall to dump all threads
Godmar Back [Thu, 13 Nov 2008 02:17:21 +0000 (21:17 -0500)]
added btthreadall to dump all threads
added loadusersymbols to load user symbols from file
updated documentation to reflect behavior of qemu's and bochs's gdbstubs

15 years agoImplement a proper block layer with partition support.
Ben Pfaff [Wed, 12 Nov 2008 06:19:01 +0000 (22:19 -0800)]
Implement a proper block layer with partition support.

This is in preparation for introducing new block devices, in
particular USB storage-based block devices so that Pintos can boot
from USB memory sticks on notebook and desktop PCs.

This block layer was inspired by one from Anthony Romano
<> but it has been extensively (perhaps entirely) rewritten.
Thus, bugs must certainly be blamed on the committer.

15 years agoMake backtraces slightly more reliable.
Ben Pfaff [Mon, 10 Nov 2008 04:07:40 +0000 (20:07 -0800)]
Make backtraces slightly more reliable.

We now ignore pointers that are not null but still clearly wild.

We could check that there's really a valid PDE and PTE (I think Linux
does this) but it would take more code and be ugly.

15 years agoAdd PC speaker driver and connect it to '\a' in the VGA console.
Ben Pfaff [Mon, 10 Nov 2008 04:02:19 +0000 (20:02 -0800)]
Add PC speaker driver and connect it to '\a' in the VGA console.

Based on code from Anthony Romano <> but with extensive changes.

15 years agoRename ram_pages to init_ram_pages.
Ben Pfaff [Sun, 9 Nov 2008 23:56:05 +0000 (15:56 -0800)]
Rename ram_pages to init_ram_pages.

This makes it conform to the Pintos convention that a global symbol name
begin with its module's name.

15 years agoGet rid of power_off_when_done global variable.
Ben Pfaff [Mon, 10 Nov 2008 00:19:48 +0000 (16:19 -0800)]
Get rid of power_off_when_done global variable.

This global variable was not named according to the convention that a
global variable name start with its module name.  Furthermore, its usage
was somewhat scattered across the source tree.

This commit introduces new functions shutdown() and shutdown_configure()
to improve the situation.

15 years agoRemove prototypes for removed functions power_off(), reboot().
Ben Pfaff [Sun, 9 Nov 2008 23:51:01 +0000 (15:51 -0800)]
Remove prototypes for removed functions power_off(), reboot().

15 years agoIgnore files produced by "makeinfo".
Ben Pfaff [Sun, 9 Nov 2008 23:42:02 +0000 (15:42 -0800)]
Ignore files produced by "makeinfo".

15 years agoMark shutdown_reboot() and shutdown_power_off() as NO_RETURN.
Ben Pfaff [Sun, 9 Nov 2008 23:40:18 +0000 (15:40 -0800)]
Mark shutdown_reboot() and shutdown_power_off() as NO_RETURN.

Also, make shutdown_reboot() actually behave that way, by trying to reboot
forever instead of giving up after some number of tries.

15 years agoAllow Bochs users to reboot by clicking the "user" button.
Ben Pfaff [Sun, 9 Nov 2008 23:21:21 +0000 (15:21 -0800)]
Allow Bochs users to reboot by clicking the "user" button.

The "user_shortcut" Bochs option allows specifying a key combination to
send to the VM when the user clicks on the "user" button in the Bochs

From Godmar, crossported from his usb-integration-aug08 branch.

15 years agoTerminate the backtrace that debug_backtrace() would output.
Ben Pfaff [Sun, 9 Nov 2008 23:22:35 +0000 (15:22 -0800)]
Terminate the backtrace that debug_backtrace() would output.

From Godmar, crossported from his usb-integration-aug08 branch.

15 years agoUse 9600 bps for Pintos serial, to match the speed used by the loader.
Ben Pfaff [Sun, 9 Nov 2008 23:22:25 +0000 (15:22 -0800)]
Use 9600 bps for Pintos serial, to match the speed used by the loader.

It is important that Pintos and its loader use the same serial speed, so
that a terminal program connected to a serial port can be set to a sane
speed.  The ideal choice would be 115200 bps, for maximum speed, but the
Pintos loader uses the BIOS to do serial output, and the BIOS supports a
maximum speed of 9600 bps.

From Godmar, crossported from his usb-integration-aug08 branch.

15 years agoMove reboot() and power_off() to new file, and rename to fit convention.
Ben Pfaff [Sun, 9 Nov 2008 19:41:18 +0000 (11:41 -0800)]
Move reboot() and power_off() to new file, and rename to fit convention.

15 years agoadded note regarding console lock
Godmar Back [Sat, 8 Nov 2008 04:48:13 +0000 (23:48 -0500)]
added note regarding console lock

15 years agoCorrect comment describing list_remove() behavior.
Ben Pfaff [Sat, 8 Nov 2008 01:23:09 +0000 (17:23 -0800)]
Correct comment describing list_remove() behavior.

Thanks to Godmar for pointing out the problem.

15 years agoAdd FAQ item to explain doubled test names in output.
Ben Pfaff [Sat, 8 Nov 2008 01:12:23 +0000 (17:12 -0800)]
Add FAQ item to explain doubled test names in output.

Suggested by Godmar.

15 years agoEliminate user_page_limit global symbol.
Ben Pfaff [Fri, 7 Nov 2008 05:54:04 +0000 (21:54 -0800)]
Eliminate user_page_limit global symbol.

The name "user_page_limit" did not follow the naming convention, which
stated that its name should start with palloc_ since it is defined in
palloc.c.  But it was only used in one function, so it was better off
as a function parameter anyhow.

Found by Godmar with his

15 years agoDon't make interrupt stubs global symbols.
Ben Pfaff [Fri, 7 Nov 2008 05:31:30 +0000 (21:31 -0800)]
Don't make interrupt stubs global symbols.

The stubs are only referenced within intr-stubs.S so there is no reason
for them to be exported.

Found with Godmar's

15 years agoRename base_page_dir to init_page_dir.
Ben Pfaff [Fri, 7 Nov 2008 05:19:34 +0000 (21:19 -0800)]
Rename base_page_dir to init_page_dir.

This makes its name fit the convention that the file name is used as
a prefix for global symbol names.

Found by Godmar with his script.

15 years agoRename schedule_tail() to thread_schedule_tail().
Ben Pfaff [Fri, 7 Nov 2008 05:55:33 +0000 (21:55 -0800)]
Rename schedule_tail() to thread_schedule_tail().

This makes its name fit the convention that the file name is used as
a prefix for global symbol names.

Found by Godmar with his script.

15 years agoMake kernel_pool, user_pool static, since they are used only in palloc.c
Ben Pfaff [Fri, 7 Nov 2008 05:12:12 +0000 (21:12 -0800)]
Make kernel_pool, user_pool static, since they are used only in palloc.c

Found by Godmar with his

15 years agoRename .cvsignore files to .gitignore.
Ben Pfaff [Fri, 7 Nov 2008 05:11:26 +0000 (21:11 -0800)]
Rename .cvsignore files to .gitignore.

15 years agoremoved trailing whitespace
Godmar Back [Wed, 5 Nov 2008 04:53:26 +0000 (23:53 -0500)]
removed trailing whitespace

15 years agoclarified specification for wait() system call
Godmar Back [Wed, 5 Nov 2008 04:31:45 +0000 (23:31 -0500)]
clarified specification for wait() system call

15 years agoadded documentation for thread_foreach functions
Godmar Back [Fri, 17 Oct 2008 03:26:23 +0000 (03:26 +0000)]
added documentation for thread_foreach functions

15 years agoAlways make the scratch disk an even multiple of a cylinder in size.
Ben Pfaff [Thu, 16 Oct 2008 22:49:48 +0000 (22:49 +0000)]
Always make the scratch disk an even multiple of a cylinder in size.

The pintos script tried to do so before but "print" and "syswrite"
are buffered differently and interfere with one another.

Thanks to Karan Misra <> for pointing out the
problem and confirming the solution.

15 years ago- added thread_foreach
Godmar Back [Wed, 27 Aug 2008 16:52:04 +0000 (16:52 +0000)]
- added thread_foreach
- added debug_backtrace_all
- updated P1 solution to take advantage of this new code

15 years agoremoved 'address' option for Bochs.
Godmar Back [Wed, 27 Aug 2008 14:34:24 +0000 (14:34 +0000)]
removed 'address' option for Bochs.
It makes Bochs > 2.2.6 fail with "[MEM0 ] ROM: System BIOS must end at 0xfffff"
and, according to
isn't even necessary for 2.2.6

15 years agocleaned up comments for reboot code and adopted GNU coding standards
Godmar Back [Wed, 27 Aug 2008 11:50:49 +0000 (11:50 +0000)]
cleaned up comments for reboot code and adopted GNU coding standards

15 years agoReboot when Ctrl+Alt+Del is pressed.
Ben Pfaff [Tue, 26 Aug 2008 03:05:05 +0000 (03:05 +0000)]
Reboot when Ctrl+Alt+Del is pressed.

Suggested by Anthony Romano.
Implementation with assistance from and reviewed by Godmar Back.

15 years agoImprove comments.
Ben Pfaff [Mon, 25 Aug 2008 03:50:49 +0000 (03:50 +0000)]
Improve comments.

Suggested by Godmar Back.

15 years agoNew option -r to reboot the VM after actions are complete.
Ben Pfaff [Sun, 24 Aug 2008 17:16:32 +0000 (17:16 +0000)]
New option -r to reboot the VM after actions are complete.

From Godmar Back, with minor tweaks.

15 years agoUse standard POSIX "ustar" format for the scratch disk.
Ben Pfaff [Sun, 24 Aug 2008 04:31:40 +0000 (04:31 +0000)]
Use standard POSIX "ustar" format for the scratch disk.

This should make it easier to work with scratch disks directly,
instead of through the "pintos" script.

With naming suggestion from Godmar Back.

15 years agoRTC support.
Ben Pfaff [Sat, 23 Aug 2008 03:52:54 +0000 (03:52 +0000)]
RTC support.

Adapted from Anthony Romano's patch with the following changes:

        * Style adjusted to fit rest of Pintos.

        * Don't modify the RTC registers.  It shouldn't be necessary.
          We shouldn't need any initialization in fact.

        * Drop rtc_set_time stub.

        * Do handle time advancing while reading the RTC registers in
          rtc_get_time, using the strategy from Linux.

        * Fix leap year handling: adding (year / 4) * 24 * 60 * 60 is
          wrong for first 2 months of a leap year; the test (year & 4)
          should be (year % 4).

        * Simplify month code.

        * Drop enable_rtc_int, disable_rtc_int, rtc_updating that are
          not needed.

        * Update documentation.

15 years agoUse macros for 8259A PIC registers, instead of writing them literally.
Ben Pfaff [Sat, 23 Aug 2008 03:44:32 +0000 (03:44 +0000)]
Use macros for 8259A PIC registers, instead of writing them literally.

Based on patch from Anthony Romano <>, so update authorship
information given that Anthony is going to be contributing quite a

15 years agoUse --build-id=none to avoid build-id sections on FC8.
Ben Pfaff [Thu, 21 Aug 2008 04:49:45 +0000 (04:49 +0000)]
Use --build-id=none to avoid build-id sections on FC8.

These build-id sections cause the Pintos ELF loader to reject
binaries.  The preferred way to eliminate them would be to add
/DISCARD/ : { *( }
to the linker script, but (as reported by Godmar Back) this causes a
segmentation fault in ld, as reported in a bug filed at:

15 years agoFix asm constraints to avoid SI, DI for byte and word access.
Ben Pfaff [Sat, 2 Aug 2008 11:30:43 +0000 (11:30 +0000)]
Fix asm constraints to avoid SI, DI for byte and word access.
Thanks to Ed Lyle Karrels <> for reporting the

15 years agoFix bug in --sim and --debug options reported by Bob Lantz.
Ben Pfaff [Fri, 18 Jul 2008 01:13:29 +0000 (01:13 +0000)]
Fix bug in --sim and --debug options reported by Bob Lantz.

15 years agoSpecify rounding for priority calculations.
Ben Pfaff [Thu, 3 Jul 2008 20:10:32 +0000 (20:10 +0000)]
Specify rounding for priority calculations.

Pointed out by Ed Karrels <>.

15 years agoNo longer recommend SourceForge.
Ben Pfaff [Thu, 3 Jul 2008 19:31:27 +0000 (19:31 +0000)]
No longer recommend SourceForge.

Really it seems like a bad idea for students.

15 years agoMake recent Texinfo accept devel.texi.
Ben Pfaff [Thu, 3 Jul 2008 19:30:05 +0000 (19:30 +0000)]
Make recent Texinfo accept devel.texi.

15 years agoWording improvements, from "Valentin I. Spitkovsky"
Ben Pfaff [Mon, 17 Mar 2008 11:56:48 +0000 (11:56 +0000)]
Wording improvements, from "Valentin I. Spitkovsky"