Database without operating system required for embedded system

Is there any database that does not require an operating system to perform operations? If yes, provide details, such as size or links, with details.

The programming language is C.

Required for embedded system programming.

+6
source share
1 answer

Well, it depends on how you define the "operating system."

  • If you define it as something with a graphical interface that runs on x86 hardware; of course; most databases will work fine on other systems.
  • If you define it as something that implements the POSIX specification or otherwise allows you to start threads or processes and provides a security measure, you will lose a few that require multithreaded operation, but you will still be fine; there are many options.
  • If you define it as something that does not have any file operations at all, and does not implement most of the standard C library, you are largely out of luck.

Your ARM-based device will almost certainly have the standard C library that comes with the toolchain. Newlib is a popular choice for deeply embedded systems; it is included by default, for example, in the free codecs CodeSourcery and YARTGO. However, before that you will need to implement some system calls. Can you do, say, printf() and the text will appear on the console? What about malloc() ? If these and other functions do not work, I suggest you implement them. Key system calls expected by Newlib:

 int _system (const char *); int _rename (const char *, const char *); int _isatty (int); clock_t _times (struct tms *); int _gettimeofday (struct timeval *, struct timezone *); void _raise (void); int _unlink (void); int _link (void); int _stat (const char *, struct stat *); int _fstat (int, struct stat *); caddr_t _sbrk (int); int _getpid (int); int _kill (int, int); void _exit (int); int _close (int); int _open (const char *, int, ...); int _write (int, char *, int); int _lseek (int, int, int); int _read (int, char *, int); 

Most of them can be stubs, but you need, for example, _write() for printf () (and other write operations), _read() for read operations, and _sbrk() for malloc functions and other memory management functions. See, for example, http://wiki.osdev.org/Porting_Newlib for a minimal implementation. Your definitions of these functions will determine how the database works; if _write () sends a character to UART, then your database will not be very useful.

When working with the standard library, sqlite and other databases should work. They will do such things in shell.c from sqlite:

 #include <stdlib.h> #include <string.h> #include <stdio.h> #include <assert.h> #include "sqlite3.h" #include <ctype.h> #include <stdarg.h> #include <signal.h> #include <pwd.h> #include <unistd.h> #include <sys/types.h> 

You need their implementation. It does not require an operating system. It will work with the C library, but without it you yourself.

+3
source

Source: https://habr.com/ru/post/920325/


All Articles