FujiNetWIFI/fujinet-firmware

Improve CP/M file performance.

Open

#917 opened on Apr 24, 2025

View on GitHub
 (0 comments) (0 reactions) (0 assignees)C (89 forks)auto 404
enhancementhelp wanted

Repository metrics

Stars
 (284 stars)
PR merge metrics
 (PR metrics pending)

Description

File I/O is slow in CP/M.

This is because for each BIOS read sector:

  • The file is opened
  • The sector is read
  • The file is closed.

A similar pattern is done for the other methods I list below, it's very atomic, but very slow.

Calls to OpenFile() in lib/runcpm/disk.h call _sys_openfile(): https://github.com/FujiNetWIFI/fujinet-firmware/blob/master/lib/runcpm/abstraction_fujinet.h#L153 and read sequential: https://github.com/FujiNetWIFI/fujinet-firmware/blob/master/lib/runcpm/abstraction_fujinet.h#L223 and write sequential: https://github.com/FujiNetWIFI/fujinet-firmware/blob/master/lib/runcpm/abstraction_fujinet.h#L263 and read random: https://github.com/FujiNetWIFI/fujinet-firmware/blob/master/lib/runcpm/abstraction_fujinet.h#L293 and write random: https://github.com/FujiNetWIFI/fujinet-firmware/blob/master/lib/runcpm/abstraction_fujinet.h#L339

This needs to be extended to hold onto the file handle, and not open the file again if it has already been opened, thus avoiding the file_open call if needed, and finding out when to best close the file when it is no longer needed (so we don't leak file descriptors! A timer?)

-Thom

Contributor guide