Compare commits

..

No commits in common. "fe94d6cf89643bc2874e5b1e24800f4cdfaecc6e" and "dbba9128a441ddeb2f3fd1751e0469cbaf04f92b" have entirely different histories.

3 changed files with 16 additions and 80 deletions

View File

@ -330,13 +330,11 @@ namespace Kernel
{ {
if (!node->blocked) if (!node->blocked)
return; return;
if (node != m_current) m_block_queue.remove_node(node);
m_block_queue.remove_node(node);
if (node->blocker) if (node->blocker)
node->blocker->remove_blocked_thread(node); node->blocker->remove_blocked_thread(node);
node->blocked = false; node->blocked = false;
if (node != m_current) m_run_queue.add_thread_to_back(node);
m_run_queue.add_thread_to_back(node);
} }
else else
{ {
@ -469,9 +467,6 @@ namespace Kernel
break; break;
if (thread_info.node == m_current || thread_info.queue == nullptr) if (thread_info.node == m_current || thread_info.queue == nullptr)
continue; continue;
// FIXME: allow load balancing with blocked threads, with this algorithm there is a race condition
if (thread_info.node->blocked)
continue;
auto least_loaded_id = find_least_loaded_processor(); auto least_loaded_id = find_least_loaded_processor();
if (least_loaded_id == Processor::current_id()) if (least_loaded_id == Processor::current_id())

View File

@ -245,34 +245,19 @@ namespace Kernel
case 'L': // Insert Line case 'L': // Insert Line
if (m_ansi_state.nums[0] == -1) if (m_ansi_state.nums[0] == -1)
m_ansi_state.nums[0] = 1; m_ansi_state.nums[0] = 1;
for (uint32_t row = m_height; row > m_row; row--)
{
const uint32_t dst_y = row - 1;
const uint32_t src_y = dst_y - m_ansi_state.nums[0];
memcpy(&m_buffer[dst_y * m_width], &m_buffer[src_y * m_width], m_width * sizeof(Cell));
for (uint32_t x = 0; x < m_width; x++)
render_from_buffer(x, dst_y);
}
for (uint32_t y_off = 0; y_off < (uint32_t)m_ansi_state.nums[0] && m_row + y_off < m_height; y_off++)
for (uint32_t x = 0; x < m_width; x++)
putchar_at(' ', x, m_row + y_off);
return reset_ansi();
case 'M':
if (m_ansi_state.nums[0] == -1)
m_ansi_state.nums[0] = 1;
if (m_row + m_ansi_state.nums[0] >= m_height)
m_ansi_state.nums[0] = m_height - m_row - 1;
for (uint32_t row = m_row; row < m_height; row++)
{
const uint32_t dst_y = row;
const uint32_t src_y = dst_y + m_ansi_state.nums[0];
memcpy(&m_buffer[dst_y * m_width], &m_buffer[src_y * m_width], m_width * sizeof(Cell));
for (uint32_t x = 0; x < m_width; x++)
render_from_buffer(x, dst_y);
}
for (uint32_t y_off = 0; y_off < (uint32_t)m_ansi_state.nums[0]; y_off++) for (uint32_t y_off = 0; y_off < (uint32_t)m_ansi_state.nums[0]; y_off++)
{
const uint32_t src_y = m_row + y_off;
const uint32_t dst_y = src_y + m_ansi_state.nums[0];
if (dst_y < m_height)
{
memcpy(&m_buffer[dst_y * m_width], &m_buffer[src_y * m_width], m_width * sizeof(Cell));
for (uint32_t x = 0; x < m_width; x++)
render_from_buffer(x, dst_y);
}
for (uint32_t x = 0; x < m_width; x++) for (uint32_t x = 0; x < m_width; x++)
putchar_at(' ', x, m_height - y_off - 1); putchar_at(' ', x, src_y);
}
return reset_ansi(); return reset_ansi();
case 'S': // Scroll Up case 'S': // Scroll Up
dprintln("Unsupported ANSI CSI character S"); dprintln("Unsupported ANSI CSI character S");

View File

@ -604,55 +604,11 @@ int remove(const char* path)
return unlink(path); return unlink(path);
} }
// TODO
int rename(const char* old, const char* _new) int rename(const char* old, const char* _new)
{ {
struct stat st; dwarnln("rename({}, {})", old, _new);
if (lstat(old, &st) == -1) ASSERT_NOT_REACHED();
return -1;
if (!S_ISREG(st.st_mode))
{
errno = ENOTSUP;
return -1;
}
if (unlink(_new) == -1 && errno != ENOENT)
return -1;
int old_fd = open(old, O_RDWR);
int new_fd = open(_new, O_RDWR | O_CREAT | O_EXCL, st.st_mode);
if (old_fd == -1 || new_fd == -1)
goto error;
for (;;)
{
char buffer[512];
ssize_t nread = read(old_fd, buffer, sizeof(buffer));
if (nread == -1)
{
unlink(_new);
goto error;
}
if (nread == 0)
break;
if (write(new_fd, buffer, nread) != nread)
{
unlink(_new);
goto error;
}
}
unlink(old);
return 0;
error:
if (old_fd != -1)
close(old_fd);
if (new_fd != -1)
close(new_fd);
return -1;
} }
void rewind(FILE* file) void rewind(FILE* file)