Compare commits
3 Commits
dbba9128a4
...
fe94d6cf89
Author | SHA1 | Date |
---|---|---|
Bananymous | fe94d6cf89 | |
Bananymous | 0a7c316ffb | |
Bananymous | e72424e01a |
|
@ -330,11 +330,13 @@ namespace Kernel
|
|||
{
|
||||
if (!node->blocked)
|
||||
return;
|
||||
m_block_queue.remove_node(node);
|
||||
if (node != m_current)
|
||||
m_block_queue.remove_node(node);
|
||||
if (node->blocker)
|
||||
node->blocker->remove_blocked_thread(node);
|
||||
node->blocked = false;
|
||||
m_run_queue.add_thread_to_back(node);
|
||||
if (node != m_current)
|
||||
m_run_queue.add_thread_to_back(node);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -467,6 +469,9 @@ namespace Kernel
|
|||
break;
|
||||
if (thread_info.node == m_current || thread_info.queue == nullptr)
|
||||
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();
|
||||
if (least_loaded_id == Processor::current_id())
|
||||
|
|
|
@ -245,19 +245,34 @@ namespace Kernel
|
|||
case 'L': // Insert Line
|
||||
if (m_ansi_state.nums[0] == -1)
|
||||
m_ansi_state.nums[0] = 1;
|
||||
for (uint32_t y_off = 0; y_off < (uint32_t)m_ansi_state.nums[0]; y_off++)
|
||||
for (uint32_t row = m_height; row > m_row; row--)
|
||||
{
|
||||
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);
|
||||
}
|
||||
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++)
|
||||
putchar_at(' ', x, src_y);
|
||||
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 x = 0; x < m_width; x++)
|
||||
putchar_at(' ', x, m_height - y_off - 1);
|
||||
return reset_ansi();
|
||||
case 'S': // Scroll Up
|
||||
dprintln("Unsupported ANSI CSI character S");
|
||||
|
|
|
@ -604,11 +604,55 @@ int remove(const char* path)
|
|||
return unlink(path);
|
||||
}
|
||||
|
||||
// TODO
|
||||
int rename(const char* old, const char* _new)
|
||||
{
|
||||
dwarnln("rename({}, {})", old, _new);
|
||||
ASSERT_NOT_REACHED();
|
||||
struct stat st;
|
||||
if (lstat(old, &st) == -1)
|
||||
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)
|
||||
|
|
Loading…
Reference in New Issue