# Persistent Media I/O in C

> The eXtremeDB disk manager supports asynchronous I/O and different multi-file formats as described in the following sections.

> ## Asynchronous file I/O

> By default, AIO is disabled. In order to use the asynchronous I/O mode, the application sets the `MCO_DB_USE_AIO` bit in the `db_params.mode_mask`, for example:

>         /* set default database parameters */
>         mco_db_params_init ( &db_params );
>         /* customize the params according to the application */
>         ...
>         db_params.mode_mask                |= MCO_DB_USE_AIO;

>         mco_db_open_dev(dbName, testdb_get_dictionary(), dev,
>                     sizeof(dev)/sizeof(dev[0]), &db_params );
>         ...

> By default, one AIO thread is started for each database and the default queue size is set to 10007. Sometimes it could be beneficial to change the number of AIO threads (for example if the database is comprised of multiple physical IO devices, or is resided on a RAID) and/or the queue size. However note that the number of I/O threads won't exceed the number of databases created in a process, regardless of the value of worker's threads passed by the application (the runtime does not allow more than one AIO thread to serve a database)

> The database runtime exports two methods:

>         void mco_aio_start(mco_size_t max_queue_length, mco_size_t n_workers);

>         void mco_aio_stop();

> (Applications do not need to call either of these methods if the default values are acceptable.)

> ## Multi-file databases

> Multi-file devices are defined in the same manner as other persistent memory devices except that they are of type `MCO_MEMORY_MULTIFILE` or `MCO_MEMORY_RAID` and must specify the property `multifile.segment_size` or `raid.level`. Please refer to the SDK samples `2-Open_Disk_Multifile` or `02-Open_Disk_Raid` for examples.

> For multifile implementations, segments can be added at runtime by means of the `mco_db_extend_dev()` function. Note that multifile segments cannot be removed.