1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082
|
VisualOS
Programer Reference
Manuel Estrada Sainz
ranty@atdot.org
ranty@soon.com
Copyright 2000 by Manuel Estrada Sainz
-------------------------------------------------------------------------------
Table of Contents
1. Introduction
2. SubSystems
Procesor
Procesor Interface -- CPU interface to the other subsystems.
Procesor Configuration -- Internal configuration.
Procesor Simulation -- Simulation of the processor
Processes -- Process Handling.
Processor Status -- Status of the processor.
Process Queues -- Process Queue Handling.
Processor Algorithms -- Interface for Algorithms.
I/O
IO Interface -- IO interface to the other subsystems.
Geometry -- Geometry of the device.
IO Simulation -- Simulation of the device
Request Queues -- IO Request Queue Handling.
IO Algorithms -- Interface for Algorithms.
IO Miscelaneous -- Other interesting functions.
Memory
Memory Interface -- MEM interface to the other subsystems.
Memory Configuration -- Internal configuration.
Memory Algorithms -- Interface for Algorithms.
Swap -- Swapping system.
Memory Status -- Status of the memory.
Memory Miscelaneous -- Other interesting functions.
Clock
Clock Interface -- CLOCK interface to the other subsystems.
Requestor
-------------------------------------------------------------------------------
Chapter 1. Introduction
This is a programers reference, so you will find lots of C code and tecnical
explanations all of it, as you can see, writen in english, as I spect to share
all this with the rest of the world via The Internet so if you don't what to
modify the code or find out how the program works internaly, then the user
manual will provably benefit you most.
-------------------------------------------------------------------------------
Chapter 2. SubSystems
The program is divided into Subsystems, which communicate with each other via a
messaging facility.
-------------------------------------------------------------------------------
Procesor
Table of Contents
Procesor Interface -- CPU interface to the other subsystems.
Procesor Configuration -- Internal configuration.
Procesor Simulation -- Simulation of the processor
Processes -- Process Handling.
Processor Status -- Status of the processor.
Process Queues -- Process Queue Handling.
Processor Algorithms -- Interface for Algorithms.
This is the subsystem responsable of executing the processes and, usualy, is
the one which generates all activity in the other subsystems as their client.
Procesor Interface
Name
Procesor Interface -- CPU interface to the other subsystems.
Synopsis
void cpu_register_proc_creat (proc_creat_callback_t func);
void cpu_register_proc_finish (proc_finish_callback_t func);
void (*proc_creat_callback_t) (gint pid);
void (*proc_finish_callback_t) (gint pid);
void CPU_terminate_proc (gint pid);
Description
This functions allow the other subsystems to interact, througth the messaging
service, with the CPU.
Details
cpu_register_proc_creat ()
void cpu_register_proc_creat (proc_creat_callback_t func);
Registers func to be called when ever a new process gets created.
func : function to be called.
cpu_register_proc_finish ()
void cpu_register_proc_finish (proc_finish_callback_t func);
Registers func to be called when ever a process is terminated.
func : function to be called.
proc_creat_callback_t ()
void (*proc_creat_callback_t) (gint pid);
Function pointer type for the callback used on cpu_register_proc_creat.
pid : Process ID of the created process.
proc_finish_callback_t ()
void (*proc_finish_callback_t) (gint pid);
Function pointer type for the callback used on cpu_register_proc_finish.
pid : Process ID of the terminated process.
CPU_terminate_proc ()
void CPU_terminate_proc (gint pid);
Terminate process pid.
pid : Process to terminates.
Procesor Configuration
Name
Procesor Configuration -- Internal configuration.
Synopsis
typedef cpu_config_t;
extern const cpu_config_t *CPU_config;
cpu_config_t* get_CPU_config (void);
Description
This is the way to find out CPU internal configuration.
Details
cpu_config_t
typedef struct {
gboolean stop_clock; /* clock should be stoped when something
interesting happens */
gboolean auto_fill_procs; /* process properties should be
filled automaticly without any
user interaction */
prop_io_params_t prop_io_params; /* current parameters for processes
IO parameters autofilling */
prop_mem_params_t prop_mem_params; /* current parametes for processes
Memory parametes autofilling */
struct { /* parameters related with the
graphical representation of the
subsystem */
gint max_graph_history; /* Maximun pixmap width for the
different representations */
gint pix_size_step;
} drawing;
} cpu_config_t;
CPU_config
extern const cpu_config_t *CPU_config;
This is a pointer to the configuration data, but should be used only for
reading.
get_CPU_config ()
cpu_config_t* get_CPU_config (void);
This is the right way to modify the configuration.
Returns : a writable pointer to the configuration data.
Procesor Simulation
Name
Procesor Simulation -- Simulation of the processor
Synopsis
typedef simul_data_t;
typedef simul_io_event_t;
typedef simul_mem_t;
typedef event_data_t;
void init_CPU_simulation (void);
void init_CPU_simulation_in_proc (proc_t *proc);
void end_CPU_simulation_in_proc (proc_t *proc);
void cpy_CPU_simulation_data (simul_data_t *dest,
simul_data_t *src);
simul_data_t* dup_CPU_simulation_data (simul_data_t *data);
void free_CPU_simulation_data (simul_data_t *data);
void free_CPU_proc_simulation_data (proc_t *proc);
void next_CPU_simulation_in_proc (proc_t *proc);
gint CPU_proc_current_page (proc_t *proc);
gint CPU_proc_next_page (proc_t *proc);
gboolean CPU_proc_current_page_is_write (proc_t *proc);
void fix_simulation_in_proc (proc_t *proc);
#define IO_BLOCK (event)
Description
This functions serve to manage the CPU's simulation and it's data structures.
Details
simul_data_t
typedef struct { /* simulation data for a process */
gint start_time; /* time of creation */
gint end_time; /* length of the process */
/* IO properties */
/* this list is never modified until process destruction */
simul_io_event_t *io_events; /* list of all io events */
simul_io_event_t *next_io_event; /* pointer to the next event */
simul_io_event_t *last_io_event; /* pointer to the last event */
/* MEM properties */
simul_mem_t *pages; /* list of memory accesses */
gint n_pages; /* number of memory accesses */
gint cur_access; /* index to the current access */
} simul_data_t;
simul_io_event_t
typedef struct { /* data for an IO event */
gint block; /* block to read */
gint time; /* time to read @block */
} simul_io_event_t;
simul_mem_t
typedef struct { /* data for a page access */
gint8 page; /* page to access */
gint8 write; /* is it a write access? */
} simul_mem_t;
event_data_t
typedef struct { /* io event data known by all the code */
gint io_block; /* block to access */
} event_data_t;
init_CPU_simulation ()
void init_CPU_simulation (void);
Initializes the simulation code.
init_CPU_simulation_in_proc ()
void init_CPU_simulation_in_proc (proc_t *proc);
prepares the data structures for simulation in process proc.
proc : process involved.
end_CPU_simulation_in_proc ()
void end_CPU_simulation_in_proc (proc_t *proc);
cleans up simulation data in proc to prepare it for termination.
Note: currently does nothing.
proc : the process involved.
cpy_CPU_simulation_data ()
void cpy_CPU_simulation_data (simul_data_t *dest,
simul_data_t *src);
Copies the contents of src into dest, allocating dynamic memory when needed.
dest : the target of the copy
src : the source for the copy
dup_CPU_simulation_data ()
simul_data_t* dup_CPU_simulation_data (simul_data_t *data);
Duplicates a simul_data_t structure.
data : a pointer to the data to be copied
Returns : a pointer to newly allocated memory with the same content of
data
free_CPU_simulation_data ()
void free_CPU_simulation_data (simul_data_t *data);
Frees all dynamic memory asociated to data, including data itself.
data : the data to be freed
free_CPU_proc_simulation_data ()
void free_CPU_proc_simulation_data (proc_t *proc);
Free all simulation related dynamic memory from the proc structure.
proc : a pointer to a proc_t structure
next_CPU_simulation_in_proc ()
void next_CPU_simulation_in_proc (proc_t *proc);
Once the process had an event it prepares the process for its next event,
making it a termination event if necesary.
proc : the process involved.
CPU_proc_current_page ()
gint CPU_proc_current_page (proc_t *proc);
proc : the process involved.
Returns : the page which proc is using on this very moment.
CPU_proc_next_page ()
gint CPU_proc_next_page (proc_t *proc);
Makes the process move to its next memory page and should be called once for
each "clock tick" that proc is running.
proc : the process involved.
Returns : the new page which the process is using.
CPU_proc_current_page_is_write ()
gboolean CPU_proc_current_page_is_write (proc_t *proc);
Checks if proc is writing to memory or only reading.
proc : the process involved.
Returns : TRUE when proc is writing to its current page.
fix_simulation_in_proc ()
void fix_simulation_in_proc (proc_t *proc);
Makes the simulation parameters of a process coherent, prevents: multiple
events at the same time, events after process termination, determines the next
event ...
proc : process whose simulation data should be fixed.
IO_BLOCK()
#define IO_BLOCK(event) (((event_data_t *)(event.data))->io_block)
Extracts the block from a IO event.
event : process event.
Processes
Name
Processes -- Process Handling.
Synopsis
proc_t* create_process (void);
proc_t* new_process (void);
void insert_process (proc_t *proc);
void free_process (proc_t *proc);
gint destroy_process (proc_t *proc);
proc_queue_t get_proc_list (void);
proc_t* get_proc_by_pid (gint pid);
void select_process (proc_t *proc);
proc_t* get_CPU_selected_proc (void);
void save_processes_to_file (void);
void load_processes_from_file (void);
#define burst (proc)
Description
This functions provide general process handling. Creation, insertion into the
system, destruction, finding a certain process...
Details
create_process ()
proc_t* create_process (void);
Do everything necesary to have a new process in the system.
Returns : the newly created process.
new_process ()
proc_t* new_process (void);
Allocate data for new process.
Note: the process will have to be inserted to have any efect.
Returns : the newly allocate process data.
insert_process ()
void insert_process (proc_t *proc);
Inserts process proc in the system.
Note: proc can be obtained with new_process.
proc : the process involved.
free_process ()
void free_process (proc_t *proc);
Definitely free all data related to proc.
Note: proc will be gone for good.
proc : process involved.
destroy_process ()
gint destroy_process (proc_t *proc);
Start considering proc a terminated process and remove it from the system.
Note: the data of proc is not freed, and proc will be saved by
save_processes_to_file.
proc : process involved.
Returns : nothing important.
get_proc_list ()
proc_queue_t get_proc_list (void);
Returns : the list of all currently running processes.
get_proc_by_pid ()
proc_t* get_proc_by_pid (gint pid);
pid : process ID
Returns : the data of process pid or NULL if there is no process with
PID pid.
select_process ()
void select_process (proc_t *proc);
Makes proc the selected process.
Note: some code will do things to the selected process.
proc : process involved.
get_CPU_selected_proc ()
proc_t* get_CPU_selected_proc (void);
Find out which is the currently selected process
Returns : the currently selected process.
save_processes_to_file ()
void save_processes_to_file (void);
Asks the user for a filename and saves all processes on the current session to
a file, ready to be loaded in a new session.
Note: Both terminated and not yet running processes will be written.
load_processes_from_file ()
void load_processes_from_file (void);
Asks the user for a filename and loads all processes it can find it it.
Note: Not all processes will be visible at once, they will be inserted at the
right time.
burst()
#define burst(proc) (proc->next_event.time - proc->time)
Calculates the current burst (time until next voluntary event) for proc.
proc : process involved.
Processor Status
Name
Processor Status -- Status of the processor.
Synopsis
typedef proc_queues_t;
const proc_queues_t* get_CPU_queues (void);
proc_t* get_CPU_current_proc (void);
proc_queue_t get_CPU_queue (gint nqueue);
proc_queue_t get_CPU_wait_queue (void);
gint request_nqueues (gint nqueues);
void move_proc_to_queue (proc_t *proc,
gint new_queue);
void move_proc_to_CPU (proc_t *proc);
gint suspend_proc (proc_t *proc);
gint wakeup_proc (proc_t *proc);
Description
Here is descrived show to find out the status of the processor, the currently
running process and all the ready queues.
There are also functions to move processes around and change the number of
ready queues.
Details
proc_queues_t
typedef struct { /* Processor status */
gint nqueues; /* Number of queues */
proc_t *current; /* Currently running process */
proc_queue_t *queue; /* Ready process queues */
proc_queue_t wait; /* Blocked processes */
} proc_queues_t;
get_CPU_queues ()
const proc_queues_t* get_CPU_queues (void);
Retrive the processor's status.
Returns : a pointer to the proc_queues_t structure.
get_CPU_current_proc ()
proc_t* get_CPU_current_proc (void);
Returns : The currently running process, which may be NULL if the
processor is idle.
get_CPU_queue ()
proc_queue_t get_CPU_queue (gint nqueue);
nqueue : requested queue.
Returns : ready queue number nqueue.
get_CPU_wait_queue ()
proc_queue_t get_CPU_wait_queue (void);
Returns : the blocked process queue.
request_nqueues ()
gint request_nqueues (gint nqueues);
Sets the number of queues for handling ready processes.
NOTE: when shrinking the lower queues, those which will be deleted, must be
empty or otherwise they will be concatenated to the first queue.
nqueues : requested number of queues.
Returns : nothing important.
move_proc_to_queue ()
void move_proc_to_queue (proc_t *proc,
gint new_queue);
Move proc to queue number new_queue.
NOTE: The proc should not be blocked.
proc : process to be moved.
new_queue : target queue for proc.
move_proc_to_CPU ()
void move_proc_to_CPU (proc_t *proc);
Starts running process proc.
NOTE: the processor should be idle.
proc : process to run.
suspend_proc ()
gint suspend_proc (proc_t *proc);
Move proc out of the way when it blocks.
proc : process involved.
Returns : nothing important.
wakeup_proc ()
gint wakeup_proc (proc_t *proc);
Move a process back when it becomes ready again letting the current algorithm
decide were to put it.
proc : process involved.
Returns : nothing important.
See Also
Process Queues
How to inspect process queues.
Process Queues
Name
Process Queues -- Process Queue Handling.
Synopsis
typedef proc_queue_t;
#define DECLARE_PROC_QUEUE (queue)
#define proc_queue_empty (queue)
#define proc_data (element)
#define proc_queue_next (element)
#define proc_queue_find (queue, proc)
#define proc_queue_len (queue)
#define proc_queue_init (queue)
#define proc_queue_foreach (queue, func, data)
#define proc_queue_concat (dest, orig1, orig2)
#define proc_queue_remove (queue, proc)
#define proc_queue_append (queue, proc)
#define proc_queue_nth (queue, n)
#define proc_queue_end (element)
Description
This are the functions to use when working with any queue of processes in the
CPU.
Details
proc_queue_t
DECLARE_PROC_QUEUE()
#define DECLARE_PROC_QUEUE(queue)
Declares a new and empty process queue with name queue.
queue : name for the queue.
proc_queue_empty()
#define proc_queue_empty(queue)
Is queue empty?
queue : process queue involved.
proc_data()
#define proc_data(element)
Retrives the process data from the queue element.
element : process queue element involved.
proc_queue_next()
#define proc_queue_next(element)
Gets the next element on the queue starting at element.
element : process queue element involved.
proc_queue_find()
#define proc_queue_find(queue, proc)
Find the queue element for process proc.
queue : process queue involved.
proc : process involved.
proc_queue_len()
#define proc_queue_len(queue)
Calculate the number of elements on queue.
queue : process queue involved.
proc_queue_init()
#define proc_queue_init(queue)
Initializes process queue queue.
Note: applyed to a non empty queue will loose all its elements.
queue : process queue involved.
proc_queue_foreach()
#define proc_queue_foreach(queue, func, data)
Will call func for every process on queue using the process pointer as the
first arguemt and data as the second.
queue : process queue involved.
func : function to be called.
data : second argument to func.
proc_queue_concat()
#define proc_queue_concat(dest, orig1, orig2)
Concatenates orig1 and orig2 into dest.
dest : Target queue.
orig1 : First source queue.
orig2 : Second source queue.
proc_queue_remove()
#define proc_queue_remove(queue, proc)
Remove proc from queue.
queue : process queue involved.
proc : process to be removed.
proc_queue_append()
#define proc_queue_append(queue, proc)
Append proc to queue.
queue : process queue involved.
proc : process to be appended.
proc_queue_nth()
#define proc_queue_nth(queue, n)
Get element number n from queue.
queue : queue involved.
n : element index.
proc_queue_end()
#define proc_queue_end(element) proc_queue_empty(element)
Is this element the end of the queue?
element : process queue element involved.
Processor Algorithms
Name
Processor Algorithms -- Interface for Algorithms.
Synopsis
typedef cpu_algorithm_t;
cpu_algorithm_t* get_CPU_current_algorithm (void);
GSList* init_CPU_algorithms (void);
gint register_CPU_algorithm (cpu_algorithm_t *algorithm);
gint deallocate_algorithm_private_data
(proc_queue_t proc_list);
gint set_CPU_heart_beat (gint freq);
gint reset_CPU_timer (void);
Description
Great effort has been devoted to making the addicion of new algorithms as easy
as posible, here is documented what there is to know to be able to write your
own algorithms.
Details
cpu_algorithm_t
typedef struct { /*This struct is all that we know about each algorithm*/
gchar * name;
gint (*select) (void);
gint (*unselect) (void); /* These two functions will be
called before and after the
use of an algorithm to let
it keep a low memory usage
when not in use.*/
gint (*clock) (void); /* timer interrupt. */
gint (*select_proc) (proc_t *proc); /* notifies the algorithm of a
process selection by the
user */
GtkWidget * process_properties;
GtkWidget * properties; /* Each algorithm will maintain
it's own properties widgets.
NULL means "no properties".
They should be set to NULL
when destroyed. If not
destroyed in "unselect" the
system will destroy them.*/
gint (*init_proc) (proc_t *proc); /* This function should allocate
and initialice algorith data
and anything else to get
a new process going, like
sticking it into a queue. */
gint (*end_proc) (proc_t *proc); /* This function should free the
algorithm specific data of
proc but should not take it
out of its queue */
gint (*event) (proc_t *proc); /* This function is called when
ever a process gets waked up
by an event and we have to
put it in some queue. */
gint (*next) (proc_t *proc); /* This function is called when
ever the current process gets
suspended waiting for some
event and we have to choose
another one to run.
It receives the suspended
process as argument just in
case its needed. */
} cpu_algorithm_t;
get_CPU_current_algorithm ()
cpu_algorithm_t* get_CPU_current_algorithm (void);
Find out which is the current algorithm.
Returns : the struct which descrives the current algorithm.
init_CPU_algorithms ()
GSList* init_CPU_algorithms (void);
Initializes the CPU algorithms code.
Mainly will call init functions for each algorithm.
Returns : a pointer to the algorithm structs linked list
register_CPU_algorithm ()
gint register_CPU_algorithm (cpu_algorithm_t *algorithm);
Each algorithm should call this function in it's initialization function to
register its algorithm struct.
algorithm : algorithm struct to register.
Returns : nothing important.
deallocate_algorithm_private_data ()
gint deallocate_algorithm_private_data
(proc_queue_t proc_list);
This function uses the algorithm's private data of each process as argument to
g_free.
This is for convinience of algorithm writers.
proc_list : queue of processes.
Returns : nothing important.
set_CPU_heart_beat ()
gint set_CPU_heart_beat (gint freq);
Set timer interrupt frequency. Which means, the calling frequency of algorithm
function clock.
Zero means that the timer interupt is not desired.
freq : new frequency in "time units".
Returns : nothing important.
reset_CPU_timer ()
gint reset_CPU_timer (void);
Resets the "time unit" counter so we will have a full timeslice until the next
interupt.
Returns : nothing important.
See Also
Process Queues
How to inspect process queues.
Processor Simulation
How simulation works.
Property Widget Facility
How to hadle numerical algorithm properties with the user without learning
GTK+.
-------------------------------------------------------------------------------
I/O
Table of Contents
IO Interface -- IO interface to the other subsystems.
Geometry -- Geometry of the device.
IO Simulation -- Simulation of the device
Request Queues -- IO Request Queue Handling.
IO Algorithms -- Interface for Algorithms.
IO Miscelaneous -- Other interesting functions.
This subsystem is responsable of accepting block disk accesses, simulating them
and reporting its client when done.
IO Interface
Name
IO Interface -- IO interface to the other subsystems.
Synopsis
void (*block_ready_callback_t) (gint block);
gint io_register_block_ready (block_ready_callback_t func);
void io_request_block (gint block);
void io_request_swap_block (gint block);
Description
This functions allow the other subsystems to interact, througth the messaging
service, with the I/O subsystem.
Details
block_ready_callback_t ()
void (*block_ready_callback_t) (gint block);
Function pointer type for the callback used on io_register_block_ready.
Function pointer type for the callback used on io_register_block_ready.
block : block number of the fulfilled IO access.
io_register_block_ready ()
gint io_register_block_ready (block_ready_callback_t func);
Instructs the IO subsystem to call func when a block access is finished.
func : function to be called when a requested block access is
finished.
Returns : nothing important.
io_request_block ()
void io_request_block (gint block);
Instructs the IO subsystem to accesses block from the data area.
block : data block to be accessed.
io_request_swap_block ()
void io_request_swap_block (gint block);
Instructs the IO subsystem to accesses block from the swap area.
block : swap block to be accessed.
Geometry
Name
Geometry -- Geometry of the device.
Synopsis
gint get_IO_blocks_per_track (void);
gint get_IO_max_data_block (void);
gint get_IO_max_swap_block (void);
gint get_IO_ntracks (void);
gint get_IO_last_data_track (void);
gint IO_request_track (io_request_t *request);
void init_IO_geometry (void);
Description
This functions serve to find out the geometry of the disk and do some
translations based on it.
Details
get_IO_blocks_per_track ()
gint get_IO_blocks_per_track (void);
Returns : the number of blocks per track.
get_IO_max_data_block ()
gint get_IO_max_data_block (void);
Returns : the maximun data block number.
get_IO_max_swap_block ()
gint get_IO_max_swap_block (void);
Returns : the maximun swap block number.
get_IO_ntracks ()
gint get_IO_ntracks (void);
Returns : the number of tracks on the disk.
get_IO_last_data_track ()
gint get_IO_last_data_track (void);
Returns : the last data track number.
IO_request_track ()
gint IO_request_track (io_request_t *request);
Calculates the track of a certain request.
request : IO request involved.
Returns : the track number corespoinding to request.
init_IO_geometry ()
void init_IO_geometry (void);
Initialices the geometry calculation code.
IO Simulation
Name
IO Simulation -- Simulation of the device
Synopsis
gint init_IO_simulation (void);
gint IO_algorithm_event (io_request_t *request);
gint get_IO_head_pos (void);
io_queue_t get_IO_reading_queue (void);
void set_IO_reading_queue (io_queue_t new_reading);
io_queue_t get_IO_requested_queue (void);
Description
This functions serve to manage the disk's simulation and it's data structures.
Details
init_IO_simulation ()
gint init_IO_simulation (void);
initialices the IO simulation code.
Returns : nothing important.
IO_algorithm_event ()
gint IO_algorithm_event (io_request_t *request);
Insert a new request in the IO subsystem using the current algorith.
Mainly passes request over to the current algorithm and puts it the the queue
of requested blocks.
request : request to be inserted.
Returns : nothing important.
get_IO_head_pos ()
gint get_IO_head_pos (void);
Returns : the track number over which the head is currently flying.
get_IO_reading_queue ()
io_queue_t get_IO_reading_queue (void);
Get all pending requests as ordered by the current algoritym.
Returns : the request's "reading" queue (ordered by the current
algorithm).
set_IO_reading_queue ()
void set_IO_reading_queue (io_queue_t new_reading);
Sets the request's "reading" queue.
This function should be called when ever the reading queue is modified by
external means, even if the pointer to the queue is not changed.
new_reading : newly ordered "reading" queue.
get_IO_requested_queue ()
io_queue_t get_IO_requested_queue (void);
Get all pending requests in order of arrival.
Returns : the request's "requested" queue (in chronological ordered).
Request Queues
Name
Request Queues -- IO Request Queue Handling.
Synopsis
typedef io_queue_t;
#define DECLARE_IO_QUEUE (queue)
#define io_queue_empty (queue)
#define io_request_data (element)
#define io_queue_next (element)
#define io_queue_len (queue)
#define io_queue_init (queue)
#define io_queue_foreach (queue, func, data)
#define io_queue_concat (dest, orig1, orig2)
#define io_queue_remove (queue, request)
#define io_queue_append (queue, request)
#define io_queue_end (element)
Description
This are the functions to use when working with any queue of requests in the IO
subsystem.
Details
io_queue_t
DECLARE_IO_QUEUE()
#define DECLARE_IO_QUEUE(queue)
Declares a new and empty request queue with name queue.
queue : name for the queue.
io_queue_empty()
#define io_queue_empty(queue)
Is queue empty?
queue : request queue involved.
io_request_data()
#define io_request_data(element)
Retrives the request data from the queue element.
element : request queue element involved.
io_queue_next()
#define io_queue_next(element)
Gets the next element on the queue starting at element.
element : request queue element involved.
io_queue_len()
#define io_queue_len(queue)
Calculate the number of elements on queue.
queue : request queue involved.
io_queue_init()
#define io_queue_init(queue)
Initializes request queue queue.
Note: applyed to a non empty queue will loose all its elements.
queue : request queue involved.
io_queue_foreach()
#define io_queue_foreach(queue, func, data)
Will call func for every request on queue using the request pointer as the
first arguemt and data as the second.
queue : request queue involved.
func : function to be called.
data : second argument to func.
io_queue_concat()
#define io_queue_concat(dest, orig1, orig2)
Concatenates orig1 and orig2 into dest.
dest : Target queue.
orig1 : First source queue.
orig2 : Second source queue.
io_queue_remove()
#define io_queue_remove(queue, request)
Remove request from queue.
queue : request queue involved.
request : request to be removed.
io_queue_append()
#define io_queue_append(queue, request)
Append request to queue.
queue : request queue involved.
request : request to be appended.
io_queue_end()
#define io_queue_end(element) io_queue_empty(element)
Is this element the end of the queue?
element : request queue element involved.
IO Algorithms
Name
IO Algorithms -- Interface for Algorithms.
Synopsis
typedef io_algorithm_t;
io_algorithm_t* get_IO_current_algorithm (void);
GSList* init_IO_algorithms (void);
gint register_IO_algorithm (io_algorithm_t *algorithm);
Description
Great effort has been devoted to making the addicion of new algorithms as easy
as posible, here is documented what there is to know to be able to write your
own algorithms.
Details
io_algorithm_t
typedef struct { /* This struct is all we know
about each algorithm */
gchar * name;
gint (*select) (void);
gint (*unselect) (void); /* These two functions will be
called before and after the
use of an algorithm to let
it keep a low memory usage
when not in use.*/
GtkWidget * properties; /* Each algorithm will maintain
it's own properties widget.
NULL means "no properties".
It should be set to NULL
when destroyed. If not
destroyed in "unselect" the
system will destroy it.*/
gint (*event) (io_request_t *request); /* This is called to inform the
algorithm of block request*/
gint (*done_reading) (void); /* This ia called to inform the
algorithm about all requested
reads been done */
} io_algorithm_t;
get_IO_current_algorithm ()
io_algorithm_t* get_IO_current_algorithm (void);
Find out which is the current algorithm.
Returns : the struct which descrives the current algorithm.
init_IO_algorithms ()
GSList* init_IO_algorithms (void);
Initializes the IO algorithms code.
Mainly will call init functions for each algorithm.
Returns : a pointer to the algorithm structs linked list.
register_IO_algorithm ()
gint register_IO_algorithm (io_algorithm_t *algorithm);
Each algorithm should call this function in it's initialization function to
register its algorithm struct.
algorithm : algorithm struct to register.
Returns : nothing important.
See Also
IO Simulation
How to inspect and manage requests.
Geometry
How manage geometry.
Property Widget Facility
How to hadle numerical algorithm properties with the user without learning
GTK+.
Request Queues
How to hadle request queues.
IO Miscelaneous
Name
IO Miscelaneous -- Other interesting functions.
Synopsis
gint io_server_init (void);
gint io_block_ready_server (io_request_t *io_request);
Description
This functions wouldn't make a proper section, but I believe that they are
relevant enough to be mencioned.
Details
io_server_init ()
gint io_server_init (void);
Called from the subsystem's code to initialize the interface code.
Returns : nothing important.
io_block_ready_server ()
gint io_block_ready_server (io_request_t *io_request);
Called from the subsystem's code to tell the client about a fulfilled request.
io_request : the fulfilled request.
Returns : nothing important.
-------------------------------------------------------------------------------
Memory
Table of Contents
Memory Interface -- MEM interface to the other subsystems.
Memory Configuration -- Internal configuration.
Memory Algorithms -- Interface for Algorithms.
Swap -- Swapping system.
Memory Status -- Status of the memory.
Memory Miscelaneous -- Other interesting functions.
This subsystem is responsable for accepting memory read and write requests,
managing memory for all processes: stealing and swapping pages as necesary.
Memory Interface
Name
Memory Interface -- MEM interface to the other subsystems.
Synopsis
void (*page_ready_callback_t) (gint pid,
gint page);
void mem_register_page_ready (page_ready_callback_t func);
gboolean mem_touch_page (proc_t *proc,
gint page,
gboolean write);
Description
This functions allow the other subsystems to interact, througth the messaging
service, with the Memory.
Details
page_ready_callback_t ()
void (*page_ready_callback_t) (gint pid,
gint page);
Function pointer type for the callback used on mem_register_page_ready.
Function pointer type for the callback used on mem_register_page_ready.
pid : the process involved.
page : the process' page which has become ready.
mem_register_page_ready ()
void mem_register_page_ready (page_ready_callback_t func);
Registers func to be called whenever a processes page becomes available in
physical memory.
func : function to be called.
mem_touch_page ()
gboolean mem_touch_page (proc_t *proc,
gint page,
gboolean write);
Access the page number page of process proc. The access will be for writing if
write is TRUE.
proc : process involved.
page : page we pretend to use.
write : are we writing to the specified page?
Returns : TRUE if the page was available and FALSE if a page fault
ocurred and the process has to wait.
Memory Configuration
Name
Memory Configuration -- Internal configuration.
Synopsis
typedef mem_config_t;
extern const mem_config_t *MEM_config;
mem_config_t* get_MEM_config (void);
Description
This is the way to find out Memory internal configuration.
Details
mem_config_t
typedef struct {
gboolean stop_clock; /* clock should be stoped when something
interesting happens */
gboolean disabled; /* this subsystem is disabled */
} mem_config_t;
MEM_config
extern const mem_config_t *MEM_config;
This is a pointer to the configuration data, but should be used only for
reading.
get_MEM_config ()
mem_config_t* get_MEM_config (void);
This is the right way to modify the configuration.
Returns : a writable pointer to the configuration data.
Memory Algorithms
Name
Memory Algorithms -- Interface for Algorithms.
Synopsis
typedef mem_algorithm_t;
mem_algorithm_t* get_MEM_current_algorithm (void);
GSList* init_MEM_algorithms (void);
void register_MEM_algorithm (mem_algorithm_t *algorithm);
Description
Great effort has been devoted to making the addicion of new algorithms as easy
as posible, here is documented what there is to know to be able to write your
own algorithms.
Details
mem_algorithm_t
typedef struct { /* This struct is all
that we know about
each algorithm */
gchar * name;
void (*select) (void);
void (*unselect) (void); /* These two functions
will be called before
and after the use of
an algorithm to let
it keep a low memory
usage when not in
use.*/
GtkWidget * properties; /* Each algorithm will
maintain it's own
properties widget.
NULL means "no
properties". It
should be set to NULL
when destroyed. If
not destroyed in
"unselect" the system
will destroy it.*/
void (*page_access) (gint pid, gint page); /* lets the algorithm
keep track of page
accesses */
gint (*select_frame) (void); /* it should return a
frame to be assigned
when out of memory */
} mem_algorithm_t;
get_MEM_current_algorithm ()
mem_algorithm_t* get_MEM_current_algorithm (void);
Find out which is the current algorithm.
Returns : the struct which descrives the current algorithm.
init_MEM_algorithms ()
GSList* init_MEM_algorithms (void);
Initializes the MEM algorithms code.
Mainly will call init functions for each algorithm.
Returns : a pointer to the algorithm structs linked list.
register_MEM_algorithm ()
void register_MEM_algorithm (mem_algorithm_t *algorithm);
Each algorithm should call this function in it's initialization function to
register its algorithm struct.
algorithm : algorithm struct to register.
Swap
Name
Swap -- Swapping system.
Synopsis
void MEM_swap_init (void);
void MEM_swapout_page (gint pid,
gint page);
void MEM_swapin_page (gint pid,
gint page,
guint32 set_flags);
Description
This functions serve to get process pages in and out of the swap device.
Details
MEM_swap_init ()
void MEM_swap_init (void);
Gets things ready to be able to swap memory in and out.
MEM_swapout_page ()
void MEM_swapout_page (gint pid,
gint page);
Writes page from Proces' pid virtual memory address space from memory into a
free block in the swap device.
pid : The Process Identification number.
page : Which one of the process' pages we what back.
MEM_swapin_page ()
void MEM_swapin_page (gint pid,
gint page,
guint32 set_flags);
Reads page from Proces' pid virtual memory address space into memory from the
swap device
If the page has never been swapped out we will suppose it is in the first free
swap block and request an IO access to it.
If the page is already swaping in then we will take note of set_flags and let
it be.
pid : The Process Identification number
page : Which one of the process' pages we what back
set_flags : This flags will be set on the frame when when one is assigned
Memory Status
Name
Memory Status -- Status of the memory.
Synopsis
typedef frame_info_t;
enum mem_frame_flags_t;
#define FRAME_LOCKED (frame)
#define FRAME_REFERENCED (frame)
#define FRAME_MODIFIED (frame)
typedef proc_pages_info_t;
#define PAGE_VALID (proc_pages, page)
#define NO_FRAME
#define NO_PAGE
#define NO_PROC
#define NO_BLOCK
void init_page_info (void);
frame_info_t* get_free_frame (void);
void put_free_frame (gint frame);
gboolean have_free_frame (void);
frame_info_t* get_frame_info (gint frame);
frame_info_t* get_frames_list (void);
frame_info_t* mem_frames_next (frame_info_t *frame);
proc_pages_info_t* get_proc_pages (gint pid,
gboolean creat);
proc_pages_info_t* get_proc_pages_list (void);
proc_pages_info_t* proc_pages_next (proc_pages_info_t *pages);
gint virt_to_phys (gint pid,
gint page);
void mem_page_invalid (gint pid,
gint page);
gint mem_assign_frame (gint pid,
gint page,
gint frame);
void mem_page_valid (gint pid,
gint page);
Description
Here is descrived show to find out the status of memory, the frames available,
what process they belong to, valid and invalid pages...
Details
frame_info_t
typedef struct { /* what there is to know about a frame */
gint frame; /* frame number */
gint proc; /* process it belongs to or NO_PROC */
gint page; /* page it belongs to of NO_PAGE */
guint32 flags; /* See mem_frame_flags_t */
guint32 private_flags; /* algorithm dependet flags */
}frame_info_t;
enum mem_frame_flags_t
typedef enum { /* bit indexes for frame flags */
MEM_FRAME_LOCKED=0, /* frame is locked and should not be
stolen of assigned */
MEM_FRAME_REFERENCED, /* frame has been referenced recently */
MEM_FRAME_MODIFIED /* frame is modified and should be writen to
swap if stolen */
} mem_frame_flags_t;
FRAME_LOCKED()
#define FRAME_LOCKED(frame) (test_bit(MEM_FRAME_LOCKED, &frame->flags))
Test whether frame is locked.
frame : frame involved.
FRAME_REFERENCED()
#define FRAME_REFERENCED(frame) (test_bit(MEM_FRAME_REFERENCED, &frame->flags))
Test whether frame has been referenced.
frame : frame involved.
FRAME_MODIFIED()
#define FRAME_MODIFIED(frame) (test_bit(MEM_FRAME_MODIFIED, &frame->flags))
Test whether frame has been modified.
frame : frame involved.
proc_pages_info_t
typedef struct { /* memory related information for a
process */
gint pid; /* process id of the process */
gint n_pages; /* number of pages its using */
guint32 bitmap; /* bitmap of valid pages */
frame_info_t *frame[MAX_PAGES]; /* frames where the pages are stored*/
gint block[MAX_PAGES]; /* swap blocks assigned to pages */
GSList *node; /* GSList link this struct is hanging
from */
} proc_pages_info_t;
PAGE_VALID()
#define PAGE_VALID(proc_pages, page) (proc_pages->bitmap & (1<<page))
Test whether page is valid in proc_pages.
proc_pages : process memory information.
page : page involved.
NO_FRAME
#define NO_FRAME -1 /* frame number when there is no frame */
NO_PAGE
#define NO_PAGE -1 /* page number when there is no page */
NO_PROC
#define NO_PROC -1 /* process number when there is no process */
NO_BLOCK
#define NO_BLOCK -1 /* block number when there is no block */
init_page_info ()
void init_page_info (void);
Initialize the code which keeps track of pages and frames.
get_free_frame ()
frame_info_t* get_free_frame (void);
Returns : a free frame if any, NULL otherwise.
put_free_frame ()
void put_free_frame (gint frame);
Give back a frame to be returned by get_free_frame later.
frame : frame to return.
have_free_frame ()
gboolean have_free_frame (void);
Returns : TRUE if we have free memory frames available.
get_frame_info ()
frame_info_t* get_frame_info (gint frame);
frame : frame involved.
Returns : frame's information data.
get_frames_list ()
frame_info_t* get_frames_list (void);
Returns : the first element on the list of frame information structures.
mem_frames_next ()
frame_info_t* mem_frames_next (frame_info_t *frame);
frame : a frame information structure.
Returns : the next frame information structure or NULL if frame is the
last element.
get_proc_pages ()
proc_pages_info_t* get_proc_pages (gint pid,
gboolean creat);
Retrives the memory related information for pid.
If there is no memory information for pid and creat is TRUE the information
will be created.
pid : process involved.
creat : it TRUE a process information structure will be created.
Returns : memory information for pid if applyable of NULL otherwise.
get_proc_pages_list ()
proc_pages_info_t* get_proc_pages_list (void);
Returns : the first element of the memory infomation structures.
proc_pages_next ()
proc_pages_info_t* proc_pages_next (proc_pages_info_t *pages);
pages : a process' memory information structure.
Returns : then next memory information structure or NULL if pages is the
last element.
virt_to_phys ()
gint virt_to_phys (gint pid,
gint page);
pid : process involved.
page : a page in pid's virtual memory.
Returns : the frame number coresponding to page in pid's address space
or NO_FRAME if there is non assigned.
mem_page_invalid ()
void mem_page_invalid (gint pid,
gint page);
Makes page of pid's address space invalid so pid will incure a page fault if it
tryes to use it.
pid : process involved.
page : invalid page.
mem_assign_frame ()
gint mem_assign_frame (gint pid,
gint page,
gint frame);
Assings frame to page in pid's address space.
pid : process involved.
page : a page in pid's address space.
frame : a free frame.
Returns : 0 if all went well -1 otherwise.
mem_page_valid ()
void mem_page_valid (gint pid,
gint page);
Makes page of pid's address space valid for pid to use.
pid : process involved.
page : valid page.
Memory Miscelaneous
Name
Memory Miscelaneous -- Other interesting functions.
Synopsis
#define MAX_FRAMES
#define MAX_PAGES
gint mem_server_init (GladeXML *xml);
gint mem_page_ready_server (gint pid,
gint page);
gint mem_page_bitmap_update_server (gint pid,
guint32 new_page_bitmap);
Description
This functions wouldn't make a proper section, but I believe that they are
relevant enough to be mencioned.
Details
MAX_FRAMES
#define MAX_FRAMES 40 /* total number of frames available */
MAX_PAGES
#define MAX_PAGES 32 /* maximun number of pages per process */
mem_server_init ()
gint mem_server_init (GladeXML *xml);
Called from the subsystem's code to initialize the interface code.
xml : Glade interface object.
Returns : nothing important.
mem_page_ready_server ()
gint mem_page_ready_server (gint pid,
gint page);
Called from the subsystem's code to tell the client about a fulfilled page
fault.
pid : process involved.
page : ready page.
Returns : nothing important.
mem_page_bitmap_update_server ()
gint mem_page_bitmap_update_server (gint pid,
guint32 new_page_bitmap);
Called from the subsystem's code to update the valid page bitmap on the client.
pid : process involved.
new_page_bitmap : valid page bitmap.
Returns : nothing important.
-------------------------------------------------------------------------------
Clock
Table of Contents
Clock Interface -- CLOCK interface to the other subsystems.
This subsystem is responsable for generating a common time reference for all
other subsystems.
Clock Interface
Name
Clock Interface -- CLOCK interface to the other subsystems.
Synopsis
gint (*tick_callback_t) (gint time);
gint clock_register_tick (tick_callback_t func);
gint get_time (void);
void CLOCK_stop (void);
Description
This functions allow the other subsystems to interact, througth the messaging
service, with the CLOCK.
Details
tick_callback_t ()
gint (*tick_callback_t) (gint time);
function pointer to be used with clock_reguster_tick.
function pointer to be used with clock_reguster_tick.
time : current time in "time units".
Returns : nothing important.
clock_register_tick ()
gint clock_register_tick (tick_callback_t func);
Instructs the CLOCK subsystem to call func for every "time unit".
func : function to be called as time goes by.
Returns : nothing important.
get_time ()
gint get_time (void);
Returns : the current time in "time units".
CLOCK_stop ()
void CLOCK_stop (void);
Tells the CLOCK to stop counting "time units".
-------------------------------------------------------------------------------
Requestor
This subsystem is not important for the general understanding of the program,
but is included here for completnes. It is there to allow the user to request I
/O data and Memory manualy acting as the client for those subsystems.
|